Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: disable background sync

ammarahm-ed8b524319df54
diff --git a/apps/mobile/app/app.js b/apps/mobile/app/app.js
index da25bbcb7..4a1f1c472 100644
--- a/apps/mobile/app/app.js
+++ b/apps/mobile/app/app.js
@@ -32,6 +32,7 @@ import { useUserStore } from "./stores/use-user-store";
import { View } from "react-native";
import { useState } from "react";
import NetInfo from "@react-native-community/netinfo";
+//import { BackgroundSync } from "./services/background-sync";
NetInfo.configure({
reachabilityUrl: "https://notesnook.com",
@@ -51,6 +52,7 @@ const App = () => {
if (appLockMode && appLockMode !== "none") {
useUserStore.getState().setVerifyUser(true);
}
+ //BackgroundSync.start();
setInit(true);
setTimeout(async () => {
SettingsService.onFirstLaunch();
diff --git a/apps/mobile/app/services/background-sync.ts b/apps/mobile/app/services/background-sync.ts
index eb9f0f80e..64b4f2f25 100644
--- a/apps/mobile/app/services/background-sync.ts
+++ b/apps/mobile/app/services/background-sync.ts
@@ -16,6 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
import BackgroundFetch from "react-native-background-fetch";
import { DatabaseLogger, db } from "../common/database";
import { AppState, AppRegistry } from "react-native";
@@ -67,10 +68,8 @@ const task = async (event: { taskId: string; timeout: boolean }) => {
BackgroundFetch.finish(taskId);
return;
}
- console.log(
- "[BackgroundFetch HeadlessTask] start: ",
- taskId,
- AppState.currentState
+ DatabaseLogger.info(
+ "[BackgroundFetch HeadlessTask] start: " + taskId + AppState.currentState
);
await onBackgroundSyncStarted();
BackgroundFetch.finish(taskId);
@@ -80,14 +79,14 @@ BackgroundFetch.registerHeadlessTask(task);
async function onBackgroundSyncStarted() {
try {
- console.log("Background Sync", "start");
+ DatabaseLogger.info("Background Sync" + "start");
await db.init();
const user = await db.user?.getUser();
if (user) {
await db.sync(true, false);
}
await Notifications.setupReminders();
- console.log("Background Sync", "end");
+ DatabaseLogger.info("Background Sync" + "end");
} catch (e) {
DatabaseLogger.error(e as Error);
console.log("Background Sync Error", (e as Error).message);
@@ -96,26 +95,28 @@ async function onBackgroundSyncStarted() {
const onBoot = async () => {
try {
- console.log("BOOT TASK STARTED");
+ DatabaseLogger.info("BOOT TASK STARTED");
await db.init();
await Notifications.setupReminders();
SettingsService.init();
if (SettingsService.get().notifNotes) {
Notifications.pinQuickNote(false);
}
- console.log("BOOT TASK COMPLETE");
+ DatabaseLogger.info("BOOT TASK COMPLETE");
} catch (e) {
console.log(e);
}
};
-AppRegistry.registerHeadlessTask(
- "com.streetwriters.notesnook.BOOT_TASK",
- () => {
- return onBoot;
- }
-);
+const registerHeadlessTask = () =>
+ AppRegistry.registerHeadlessTask(
+ "com.streetwriters.notesnook.BOOT_TASK",
+ () => {
+ return onBoot;
+ }
+ );
export const BackgroundSync = {
- start
+ start,
+ registerHeadlessTask
};
diff --git a/apps/mobile/native/android/app/src/main/AndroidManifest.xml b/apps/mobile/native/android/app/src/main/AndroidManifest.xml
index c3f579a08..3042a96c5 100644
--- a/apps/mobile/native/android/app/src/main/AndroidManifest.xml
+++ b/apps/mobile/native/android/app/src/main/AndroidManifest.xml
@@ -152,12 +152,12 @@
android:resource="@xml/file_viewer_provider_paths" />
</provider>
- <receiver android:exported="true" android:name=".BootRecieverService" >
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- <action android:name="android.intent.action.QUICKBOOT_POWERON" />
- </intent-filter>
- </receiver>
+<!-- <receiver android:exported="true" android:name=".BootRecieverService" >-->
+<!-- <intent-filter>-->
+<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />-->
+<!-- <action android:name="android.intent.action.QUICKBOOT_POWERON" />-->
+<!-- </intent-filter>-->
+<!-- </receiver>-->
</application>
diff --git a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java
index 2abc39f14..3e1c30533 100644
--- a/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java
+++ b/apps/mobile/native/android/app/src/main/java/com/streetwriters/notesnook/BootTaskService.java
@@ -8,7 +8,7 @@ import javax.annotation.Nullable;
public class BootTaskService extends HeadlessJsTaskService {
- @Override
+ @Override
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
return new HeadlessJsTaskConfig(
"com.streetwriters.notesnook.BOOT_TASK",
diff --git a/apps/mobile/native/index.js b/apps/mobile/native/index.js
index 3a627cdc4..69dfbef7c 100644
--- a/apps/mobile/native/index.js
+++ b/apps/mobile/native/index.js
@@ -8,7 +8,7 @@ import Config from 'react-native-config';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import appJson from './app.json';
import Notifications from '../app/services/notifications';
-import {BackgroundSync} from '../app/services/background-sync';
+//import {BackgroundSync} from '../app/services/background-sync';
const appName = appJson.name;
if (Config.isTesting) {
@@ -22,8 +22,8 @@ if (__DEV__) {
LogBox.ignoreAllLogs();
}
let NotesnookShare;
-BackgroundSync.start();
Notifications.init();
+//BackgroundSync.registerHeadlessTask();
let QuickNoteIOS;
const AppProvider = () => {