Skip to content

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

mobile: fix db init in background failing

Ammar Ahmed3ae40c09fc84
diff --git a/apps/mobile/app/services/background-sync.ts b/apps/mobile/app/services/background-sync.ts
index a5ad8e2a0..32a43e67f 100644
--- a/apps/mobile/app/services/background-sync.ts
+++ b/apps/mobile/app/services/background-sync.ts
@@ -22,7 +22,7 @@ import {
endBackgroundTask
} from "react-native-begin-background-task";
import BackgroundFetch from "@ammarahmed/react-native-background-fetch";
-import { DatabaseLogger, db } from "../common/database";
+import { DatabaseLogger, db, setupDatabase } from "../common/database";
import { AppState, AppRegistry } from "react-native";
import Notifications from "./notifications";
import SettingsService from "./settings";
@@ -110,6 +110,7 @@ BackgroundFetch.registerHeadlessTask(task);
async function onBackgroundSyncStarted() {
try {
if (!db.isInitialized) {
+ await setupDatabase();
await db.init();
}
const user = await db.user?.getUser();