A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
refactor: remove electroneventmanager; use appeventmanager
thecodrra1ecdc554f30
diff --git a/apps/web/src/commands/index.js b/apps/web/src/commands/index.jsindex 47e072dd4..76b5da240 100644--- a/apps/web/src/commands/index.js+++ b/apps/web/src/commands/index.js@@ -1,8 +1,6 @@-import EventManager from "notes-core/utils/eventmanager";+import { AppEventManager } from "../common/app-events";import { isDesktop } from "../utils/platform";-export const ElectronEventManager = new EventManager();-export function invokeCommand(type, payload = {}) {if (!isDesktop()) return;@@ -16,6 +14,6 @@ if (isDesktop()) {window.api.receive("fromMain", (args) => {console.log(args);const { type } = args;- ElectronEventManager.publish(type, args);+ AppEventManager.publish(type, args);});}diff --git a/apps/web/src/hooks/use-auto-updater.js b/apps/web/src/hooks/use-auto-updater.jsindex e4d3b3b81..210b9b8c6 100644--- a/apps/web/src/hooks/use-auto-updater.js+++ b/apps/web/src/hooks/use-auto-updater.js@@ -1,5 +1,5 @@import { useEffect, useState } from "react";-import { ElectronEventManager } from "../commands";+import { AppEventManager } from "../common/app-events";import { EVENTS } from "@notesnook/desktop/events";import { isDesktop } from "../utils/platform";import checkForUpdate from "../commands/check-for-update";@@ -37,17 +37,23 @@ export default function useAutoUpdater() {changeStatus({ type: "downloading", progress: progressInfo.percent });}- ElectronEventManager.subscribe(EVENTS.checkingForUpdate, checkingForUpdate);- ElectronEventManager.subscribe(EVENTS.updateAvailable, updateAvailable);- ElectronEventManager.subscribe(+ const checkingForUpdateEvent = AppEventManager.subscribe(+ EVENTS.checkingForUpdate,+ checkingForUpdate+ );+ const updateAvailableEvent = AppEventManager.subscribe(+ EVENTS.updateAvailable,+ updateAvailable+ );+ const updateNotAvailableEvent = AppEventManager.subscribe(EVENTS.updateNotAvailable,updateNotAvailable);- ElectronEventManager.subscribe(+ const updateCompletedEvent = AppEventManager.subscribe(EVENTS.updateDownloadCompleted,updateDownloadCompleted);- ElectronEventManager.subscribe(+ const updateProgressEvent = AppEventManager.subscribe(EVENTS.updateDownloadProgress,updateDownloadProgress);@@ -55,10 +61,13 @@ export default function useAutoUpdater() {if (isDesktop()) {checkingForUpdate();checkForUpdate();- }return () => {- ElectronEventManager.unsubscribeAll();+ checkingForUpdateEvent.unsubscribe();+ updateAvailableEvent.unsubscribe();+ updateNotAvailableEvent.unsubscribe();+ updateCompletedEvent.unsubscribe();+ updateProgressEvent.unsubscribe();};}, []);diff --git a/apps/web/src/utils/use-system-theme.js b/apps/web/src/utils/use-system-theme.jsindex bfd0a40ce..850fe2ac9 100644--- a/apps/web/src/utils/use-system-theme.js+++ b/apps/web/src/utils/use-system-theme.js@@ -1,6 +1,6 @@import { EVENTS } from "@notesnook/desktop/events";import { useEffect, useState } from "react";-import { ElectronEventManager } from "../commands";+import { AppEventManager } from "../common/app-events";import useMediaQuery from "./use-media-query";function useSystemTheme() {@@ -15,9 +15,9 @@ function useSystemTheme() {function onThemeChanged({ theme }) {setSystemTheme(theme);}- ElectronEventManager.subscribe(EVENTS.themeChanged, onThemeChanged);+ AppEventManager.subscribe(EVENTS.themeChanged, onThemeChanged);return () => {- ElectronEventManager.unsubscribe(EVENTS.themeChanged, onThemeChanged);+ AppEventManager.unsubscribe(EVENTS.themeChanged, onThemeChanged);};}, []);