core: handle triggerSync & inboxUpdated SSEs (#9963)

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2026-06-11 09:23:56 +05:00
committed by GitHub
parent 9c103ea0e3
commit c7e0225535
3 changed files with 23 additions and 1 deletions

View File

@@ -50,6 +50,7 @@ export default function AppEffects() {
const isFocusMode = useStore((store) => store.isFocusMode);
const initUser = useUserStore((store) => store.init);
const initStore = useStore((store) => store.init);
const initSettingStore = useSettingStore((store) => store.init);
const setIsVaultCreated = useStore((store) => store.setIsVaultCreated);
const initEditorStore = useEditorStore((store) => store.init);
const dialogAnnouncements = useAnnouncementStore(
@@ -59,6 +60,7 @@ export default function AppEffects() {
useEffect(
function initializeApp() {
initStore();
initSettingStore();
(async function () {
await initEditorStore();

View File

@@ -23,7 +23,7 @@ import { desktop } from "../common/desktop-bridge";
import createStore from "../common/store";
import Config from "../utils/config";
import BaseStore from "./index";
import { TimeFormat, DayFormat, WeekFormat } from "@notesnook/core";
import { TimeFormat, DayFormat, WeekFormat, EVENTS } from "@notesnook/core";
import { Profile, TrashCleanupInterval } from "@notesnook/core";
import { showToast } from "../utils/toast";
import { ConfirmDialog } from "../dialogs/confirm";
@@ -93,6 +93,14 @@ class SettingStore extends BaseStore<SettingStore> {
proxyRules?: string;
isInboxEnabled = false;
init = () => {
db.eventManager.subscribe(EVENTS.userFetched, async () => {
this.set({
isInboxEnabled: await db.user.hasInboxKeys()
});
});
};
refresh = async () => {
this.set({
dateFormat: db.settings.getDateFormat(),

View File

@@ -431,6 +431,18 @@ class Database {
this.eventManager.publish(EVENTS.userEmailConfirmed);
break;
}
case "triggerSync": {
this.eventManager.publish(
EVENTS.databaseSyncRequested,
true,
false
);
break;
}
case "inboxUpdated": {
await this.user.fetchUser();
break;
}
}
} catch (e) {
logger.error("SSE: Unsupported message. Message = ", event.data);