Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

refactor: move appeventmanager to its own file

thecodrr9d8f7bca6d35
diff --git a/apps/web/src/app-effects.js b/apps/web/src/app-effects.js
index 9c29b445b..26080d942 100644
--- a/apps/web/src/app-effects.js
+++ b/apps/web/src/app-effects.js
@@ -4,12 +4,8 @@ import { useStore as useUserStore } from "./stores/user-store";
import { useStore as useNotesStore } from "./stores/note-store";
import { useStore as useThemeStore } from "./stores/theme-store";
import { resetReminders } from "./common/reminders";
-import {
- AppEventManager,
- AppEvents,
- introduceFeatures,
- showUpgradeReminderDialogs,
-} from "./common";
+import { introduceFeatures, showUpgradeReminderDialogs } from "./common";
+import { AppEventManager, AppEvents } from "./common/app-events";
import { db } from "./common/db";
import { CHECK_IDS, EV, EVENTS } from "notes-core/common";
import { registerKeyMap } from "./common/key-map";
diff --git a/apps/web/src/common/app-events.js b/apps/web/src/common/app-events.js
new file mode 100644
index 000000000..9ae4db4ae
--- /dev/null
+++ b/apps/web/src/common/app-events.js
@@ -0,0 +1,9 @@
+import EventManager from "notes-core/utils/eventmanager";
+
+export const AppEventManager = new EventManager();
+export const AppEvents = {
+ UPDATE_ATTACHMENT_PROGRESS: "updateAttachmentProgress",
+ UPDATE_WORD_COUNT: "updateWordCount",
+ UPDATE_STATUS: "updateStatus",
+ REMOVE_STATUS: "removeStatus",
+};
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index d0e165c9e..d0a1b5c1d 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -11,7 +11,6 @@ import { hashNavigate, getCurrentHash } from "../navigation";
import { db } from "./db";
import { sanitizeFilename } from "../utils/filename";
import { isTesting } from "../utils/platform";
-import EventManager from "notes-core/utils/eventmanager";
import { store as userstore } from "../stores/user-store";
export const COLORS = [
@@ -133,12 +132,6 @@ export async function verifyAccount() {
});
}
-export const AppEventManager = new EventManager();
-export const AppEvents = {
- UPDATE_ATTACHMENT_PROGRESS: "updateAttachmentProgress",
- UPDATE_WORD_COUNT: "updateWordCount",
-};
-
export function totalSubscriptionConsumed(user) {
if (!user) return 0;
const start = user.subscription?.start;
diff --git a/apps/web/src/components/editor/footer.js b/apps/web/src/components/editor/footer.js
index 5354500a7..8ebe5b2ae 100644
--- a/apps/web/src/components/editor/footer.js
+++ b/apps/web/src/components/editor/footer.js
@@ -1,7 +1,7 @@
import { formatDate } from "notes-core/utils/date";
import React, { useEffect, useState } from "react";
import { Flex, Text } from "rebass";
-import { AppEventManager, AppEvents } from "../../common";
+import { AppEventManager, AppEvents } from "../../common/app-events";
import { useStore } from "../../stores/editor-store";
function EditorFooter() {
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 71a093327..8df092d08 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -18,7 +18,7 @@ import Header from "./header";
import Toolbar from "./toolbar";
import EditorLoading from "./loading";
import { db } from "../../common/db";
-import { AppEventManager, AppEvents } from "../../common";
+import { AppEventManager, AppEvents } from "../../common/app-events";
import debounce from "just-debounce-it";
import { FlexScrollContainer } from "../scroll-container";
import { formatDate } from "notes-core/utils/date";
diff --git a/apps/web/src/components/editor/plugins/picker.js b/apps/web/src/components/editor/plugins/picker.js
index ceb912743..4ccce6d4c 100644
--- a/apps/web/src/components/editor/plugins/picker.js
+++ b/apps/web/src/components/editor/plugins/picker.js
@@ -1,5 +1,5 @@
import Compressor from "compressorjs";
-import { AppEventManager, AppEvents } from "../../../common";
+import { AppEventManager, AppEvents } from "../../../common/app-events";
import { db } from "../../../common/db";
import {
showBuyDialog,
diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.js
index 7bd64793a..2d111b3ec 100644
--- a/apps/web/src/components/editor/tinymce.js
+++ b/apps/web/src/components/editor/tinymce.js
@@ -43,7 +43,7 @@ import { useStore as useThemeStore } from "../../stores/theme-store";
import { isTablet } from "../../utils/dimensions";
import { showToast } from "../../utils/toast";
import { useIsUserPremium } from "../../hooks/use-is-user-premium";
-import { AppEventManager, AppEvents } from "../../common";
+import { AppEventManager, AppEvents } from "../../common/app-events";
import { EV, EVENTS } from "notes-core/common";
import { downloadAttachment } from "../../common/attachments";
import debounce from "just-debounce-it";
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index 9c5292c80..f25188b96 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -2,7 +2,8 @@ import React, { useCallback, useEffect, useState } from "react";
import * as Icon from "../icons";
import { Flex, Text, Button, Box } from "rebass";
import { useStore } from "../../stores/editor-store";
-import { AppEventManager, AppEvents, COLORS } from "../../common";
+import { COLORS } from "../../common";
+import { AppEventManager, AppEvents } from "../../common/app-events";
import { db } from "../../common/db";
import { useStore as useAppStore } from "../../stores/app-store";
import { AnimatedFlex } from "../animated";
diff --git a/apps/web/src/interfaces/fs.js b/apps/web/src/interfaces/fs.js
index 481bb1de8..7801225ff 100644
--- a/apps/web/src/interfaces/fs.js
+++ b/apps/web/src/interfaces/fs.js
@@ -2,7 +2,7 @@ import "web-streams-polyfill/dist/ponyfill";
import localforage from "localforage";
import { xxhash64, createXXHash64 } from "hash-wasm";
import axios from "axios";
-import { AppEventManager, AppEvents } from "../common";
+import { AppEventManager, AppEvents } from "../common/app-events";
import { StreamableFS } from "streamablefs";
import { getNNCrypto } from "./nncrypto.stub";
import hosts from "notes-core/utils/constants";