mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
mobile: add sync controls
This commit is contained in:
committed by
Abdullah Atta
parent
db4126fe16
commit
2845cb19d6
@@ -277,6 +277,7 @@ export const useAppEvents = () => {
|
||||
};
|
||||
|
||||
const onRequestPartialSync = async (full, force) => {
|
||||
if (SettingsService.get().disableAutoSync) return;
|
||||
DatabaseLogger.info(`onRequestPartialSync full:${full}, force:${force}`);
|
||||
if (full || force) {
|
||||
await Sync.run("global", force, full);
|
||||
|
||||
@@ -381,27 +381,52 @@ export const settingsGroups: SettingSection[] = [
|
||||
]
|
||||
},
|
||||
{
|
||||
id: "sync-issues-fix",
|
||||
name: "Having problems with sync",
|
||||
description: "Try force sync to resolve issues with syncing",
|
||||
icon: "sync-alert",
|
||||
modifer: async () => {
|
||||
presentDialog({
|
||||
title: "Force sync",
|
||||
paragraph:
|
||||
"If your data on two devices is out of sync even after trying to sync normally. You can run force sync to solve such problems. Usually you should never need to run this otherwise. Force sync means that all your data on this device is reuploaded to the server.",
|
||||
negativeText: "Cancel",
|
||||
positiveText: "Start",
|
||||
positivePress: async () => {
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
await sleep(300);
|
||||
Progress.present();
|
||||
Sync.run("global", true, true, () => {
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
id: "sync-settings",
|
||||
name: "Sync settings",
|
||||
description: "Configure syncing for this device",
|
||||
type: "screen",
|
||||
icon: "autorenew",
|
||||
sections: [
|
||||
{
|
||||
id: "auto-sync",
|
||||
name: "Disable auto sync",
|
||||
description:
|
||||
"Turn of automatic syncing. Changes from this client will be synced only when you run sync manually.",
|
||||
type: "switch",
|
||||
property: "disableAutoSync"
|
||||
},
|
||||
{
|
||||
id: "disable-sync",
|
||||
name: "Disable syncing",
|
||||
description:
|
||||
"Turns off syncing completely on this device. Any changes made will remain local only and new changes from your other devices won't sync to this device.",
|
||||
type: "switch",
|
||||
property: "disableSync",
|
||||
},
|
||||
{
|
||||
id: "sync-issues-fix",
|
||||
name: "Having problems with sync",
|
||||
description: "Try force sync to resolve issues with syncing",
|
||||
icon: "sync-alert",
|
||||
modifer: async () => {
|
||||
presentDialog({
|
||||
title: "Force sync",
|
||||
paragraph:
|
||||
"If your data on two devices is out of sync even after trying to sync normally. You can run force sync to solve such problems. Usually you should never need to run this otherwise. Force sync means that all your data on this device is reuploaded to the server.",
|
||||
negativeText: "Cancel",
|
||||
positiveText: "Start",
|
||||
positivePress: async () => {
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
await sleep(300);
|
||||
Progress.present();
|
||||
Sync.run("global", true, true, () => {
|
||||
eSendEvent(eCloseProgressDialog);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -25,6 +25,7 @@ import { doInBackground } from "../utils";
|
||||
import { db } from "../common/database";
|
||||
import { DatabaseLogger } from "../common/database/index";
|
||||
import { ToastEvent } from "./event-manager";
|
||||
import SettingsService from "./settings";
|
||||
|
||||
NetInfo.configure({
|
||||
reachabilityUrl: "https://notesnook.com",
|
||||
@@ -56,7 +57,11 @@ const run = async (
|
||||
if (!status.isInternetReachable) {
|
||||
DatabaseLogger.warn("Internet not reachable");
|
||||
}
|
||||
if (!user || !status.isInternetReachable) {
|
||||
if (
|
||||
!user ||
|
||||
!status.isInternetReachable ||
|
||||
SettingsService.get().disableSync
|
||||
) {
|
||||
initAfterSync();
|
||||
return onCompleted?.(false);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ export type Settings = {
|
||||
sessionExpired: boolean;
|
||||
version: string | null;
|
||||
doubleSpacedLines?: boolean;
|
||||
disableAutoSync?: boolean;
|
||||
disableSync?: boolean;
|
||||
};
|
||||
|
||||
type DimensionsType = {
|
||||
|
||||
Reference in New Issue
Block a user