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
mobile: add null checks before setting items on storage
Ammar Ahmed5cae4eb0d9b2
diff --git a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts b/apps/mobile/app/screens/editor/tiptap/use-tab-store.tsindex 3166eedba..48aa8fcb7 100644--- a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts@@ -97,15 +97,16 @@ class TabSessionStorage {static storage: typeof TabSessionStorageKV = TabSessionStorageKV;static get(id: string): TabSessionItem | null {+ if (!id) return null;return TabSessionStorage.storage.getMap(id);}static set(id: string, session: TabSessionItem): void {+ if (!id) return;TabSessionStorage.storage.setMap(id, session);}static update(id: string, session: Partial<TabSessionItem>) {- if (!id) throw new Error("Session ID is required");const currentSession = TabSessionStorage.get(id);const newSession = {...currentSession,@@ -118,6 +119,7 @@ class TabSessionStorage {}static remove(id: string) {+ if (!id) return;TabSessionStorageKV.removeItem(id);}}@@ -317,13 +319,15 @@ export const useTabStore = create<TabStore>(const sessionLoaded = await get().loadSession(id);if (!sessionLoaded) {- tabSessionHistory.remove(currentTab, id);- TabSessionStorage.remove(id);- if (!tabSessionHistory.canGoBack(currentTab)) {+ const canGoBack = tabSessionHistory.canGoBack(currentTab);+ if (!canGoBack) {tabSessionHistory.forward(currentTab);syncTabs();} else {- return get().goBack();+ get().goBack();+ tabSessionHistory.remove(currentTab, id);+ TabSessionStorage.remove(id);+ return;}} else {syncTabs();@@ -336,13 +340,15 @@ export const useTabStore = create<TabStore>(if (!tabSessionHistory.canGoForward(currentTab)) return;const id = tabSessionHistory.forward(currentTab) as string;if (!(await get().loadSession(id))) {- tabSessionHistory.remove(currentTab, id);- TabSessionStorage.remove(id);- if (!tabSessionHistory.canGoForward(currentTab)) {+ const canGoForward = tabSessionHistory.canGoForward(currentTab);+ if (!canGoForward) {tabSessionHistory.back(currentTab);syncTabs();} else {- return get().goForward();+ get().goForward();+ tabSessionHistory.remove(currentTab, id);+ TabSessionStorage.remove(id);+ return;}} else {syncTabs();@@ -399,7 +405,7 @@ export const useTabStore = create<TabStore>(set({tabs: [{ id: id }]});- get().newTabSession(id, {});+ get().newTabSession(id);get().focusTab(id);} else {set({