mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
mobile: stop bg fetch events when toggled off
This commit is contained in:
committed by
Abdullah Atta
parent
8736a58a02
commit
c8eea0a0e4
@@ -57,10 +57,10 @@ const _SectionItem = ({ item }: { item: SettingSection }) => {
|
||||
return;
|
||||
}
|
||||
if (!item.property) return;
|
||||
item.onChange?.(!settings[item.property]);
|
||||
SettingsService.set({
|
||||
[item.property]: !settings[item.property]
|
||||
});
|
||||
item.onChange?.(!settings[item.property]);
|
||||
};
|
||||
|
||||
const styles =
|
||||
|
||||
@@ -70,6 +70,7 @@ import { SettingSection } from "./types";
|
||||
import { getTimeLeft } from "./user-section";
|
||||
import { AppLockPassword } from "../../components/dialogs/applock-password";
|
||||
import { validateAppLockPassword } from "../../common/database/encryption";
|
||||
import { BackgroundSync } from "../../services/background-sync";
|
||||
type User = any;
|
||||
|
||||
export const settingsGroups: SettingSection[] = [
|
||||
@@ -406,7 +407,14 @@ export const settingsGroups: SettingSection[] = [
|
||||
description:
|
||||
"Periodically wake up the app in background to sync your notes from other devices.",
|
||||
type: "switch",
|
||||
property: "backgroundSync"
|
||||
property: "backgroundSync",
|
||||
onChange: (value) => {
|
||||
if (value) {
|
||||
BackgroundSync.start();
|
||||
} else {
|
||||
BackgroundSync.stop();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "sync-issues-fix",
|
||||
|
||||
@@ -87,6 +87,7 @@ async function start() {
|
||||
onEvent,
|
||||
onTimeout
|
||||
);
|
||||
|
||||
DatabaseLogger.info(`[BackgroundFetch] configure status: ${status}`);
|
||||
}
|
||||
|
||||
@@ -159,7 +160,10 @@ const registerHeadlessTask = () =>
|
||||
);
|
||||
export const BackgroundSync = {
|
||||
start,
|
||||
registerHeadlessTask
|
||||
registerHeadlessTask,
|
||||
stop: () => {
|
||||
BackgroundFetch.stop();
|
||||
}
|
||||
};
|
||||
|
||||
export default { doInBackground };
|
||||
|
||||
Reference in New Issue
Block a user