mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-07-09 20:09:36 +02:00
core: handle triggerSync & inboxUpdated SSEs (#9963)
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user