From 5164bf4414ff469432ca85be1c8a6fc40ef624c8 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Fri, 15 Jul 2022 15:54:08 +0500 Subject: [PATCH] fix: auto close note on logout --- apps/web/src/app-effects.js | 7 ++++++- apps/web/src/components/editor/index.tsx | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/web/src/app-effects.js b/apps/web/src/app-effects.js index ac5349196..8baf1b4e4 100644 --- a/apps/web/src/app-effects.js +++ b/apps/web/src/app-effects.js @@ -4,6 +4,7 @@ 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 { useStore as useAttachmentStore } from "./stores/attachment-store"; +import { useStore as useEditorStore } from "./stores/editor-store"; import { resetReminders } from "./common/reminders"; import { introduceFeatures, showUpgradeReminderDialogs } from "./common"; import { AppEventManager, AppEvents } from "./common/app-events"; @@ -11,7 +12,6 @@ import { db } from "./common/db"; import { CHECK_IDS, EV, EVENTS } from "@streetwriters/notesnook-core/common"; import { registerKeyMap } from "./common/key-map"; import { isUserPremium } from "./hooks/use-is-user-premium"; -import { loadTrackerScript } from "./utils/analytics"; import useAnnouncements from "./utils/use-announcements"; import { showAnnouncementDialog, @@ -39,6 +39,7 @@ export default function AppEffects({ setShow }) { const setIsVaultCreated = useStore((store) => store.setIsVaultCreated); const setTheme = useThemeStore((store) => store.setTheme); const followSystemTheme = useThemeStore((store) => store.followSystemTheme); + const initEditorStore = useEditorStore((store) => store.init); const [announcements, remove] = useAnnouncements("dialog"); const isSystemThemeDark = useSystemTheme(); @@ -72,6 +73,8 @@ export default function AppEffects({ setShow }) { initAttachments(); refreshNavItems(); initNotes(); + initEditorStore(); + (async function () { await updateLastSynced(); if (await initUser()) { @@ -83,11 +86,13 @@ export default function AppEffects({ setShow }) { await showOnboardingDialog(interruptedOnboarding()); await showFeatureDialog("highlights"); })(); + return () => { userCheckStatusEvent.unsubscribe(); }; }, [ + initEditorStore, initStore, initAttachments, sync, diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx index a6c915ef2..3d402e744 100644 --- a/apps/web/src/components/editor/index.tsx +++ b/apps/web/src/components/editor/index.tsx @@ -74,8 +74,6 @@ export default function EditorManager({ const isReadonly = useStore( (store) => store.session.readonly || !!previewSession.current ); - // TODO move this somewhere more appropriate - // const init = useStore((store) => store.init); const openSession = useCallback(async (noteId) => { await editorstore.get().openSession(noteId);