diff --git a/apps/web/src/dialogs/settings/sync-settings.ts b/apps/web/src/dialogs/settings/sync-settings.ts index 9e1acc484..218680a89 100644 --- a/apps/web/src/dialogs/settings/sync-settings.ts +++ b/apps/web/src/dialogs/settings/sync-settings.ts @@ -19,6 +19,7 @@ along with this program. If not, see . import { SettingsGroup } from "./types"; import { useStore as useAppStore } from "../../stores/app-store"; +import { useStore as useSettingStore } from "../../stores/setting-store"; import { ConfirmDialog } from "../confirm"; export const SyncSettings: SettingsGroup[] = [ @@ -76,6 +77,21 @@ export const SyncSettings: SettingsGroup[] = [ } ] }, + { + key: "full-offline-mode", + title: "Full offline mode", + description: "Download everything including attachments on sync", + keywords: ["offline mode"], + onStateChange: (listener) => + useSettingStore.subscribe((s) => s.isFullOfflineMode, listener), + components: [ + { + type: "toggle", + isToggled: () => useSettingStore.getState().isFullOfflineMode, + toggle: () => useSettingStore.getState().toggleFullOfflineMode() + } + ] + }, { key: "force-sync", title: "Having problems with sync?", diff --git a/apps/web/src/stores/setting-store.ts b/apps/web/src/stores/setting-store.ts index e52f02111..4394baccd 100644 --- a/apps/web/src/stores/setting-store.ts +++ b/apps/web/src/stores/setting-store.ts @@ -39,6 +39,7 @@ class SettingStore extends BaseStore { doubleSpacedParagraphs = Config.get("doubleSpacedLines", true); markdownShortcuts = Config.get("markdownShortcuts", true); notificationsSettings = Config.get("notifications", { reminder: true }); + isFullOfflineMode = false; zoomFactor = 1.0; privacyMode = false; @@ -71,7 +72,8 @@ class SettingStore extends BaseStore { customDns: await desktop?.integration.customDns.query(), zoomFactor: await desktop?.integration.zoomFactor.query(), autoUpdates: await desktop?.updater.autoUpdates.query(), - proxyRules: await desktop?.integration.proxyRules.query() + proxyRules: await desktop?.integration.proxyRules.query(), + isFullOfflineMode: await db.kv().read("fullOfflineMode") }); }; @@ -201,6 +203,12 @@ class SettingStore extends BaseStore { this.set({ autoUpdates: !autoUpdates }); await desktop?.updater.toggleAutoUpdates.mutate({ enabled: !autoUpdates }); }; + + toggleFullOfflineMode = async () => { + const isFullOfflineMode = this.get().isFullOfflineMode; + this.set({ isFullOfflineMode: !isFullOfflineMode }); + await db.kv().write("fullOfflineMode", !isFullOfflineMode); + }; } const [useStore, store] = createStore(