web: add setting to toggle full offline mode

This commit is contained in:
Abdullah Atta
2024-07-24 12:39:32 +05:00
committed by Abdullah Atta
parent 57ddaafc16
commit 398432efde
2 changed files with 25 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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?",

View File

@@ -39,6 +39,7 @@ class SettingStore extends BaseStore<SettingStore> {
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<SettingStore> {
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<SettingStore> {
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<SettingStore>(