diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.ts index 714eb238b..b89b5656c 100644 --- a/apps/mobile/app/services/notifications.ts +++ b/apps/mobile/app/services/notifications.ts @@ -202,15 +202,14 @@ const onEvent = async ({ type, detail }: Event) => { reply_button_text: "Take note", reply_placeholder_text: "Write something..." }); - await initDatabase(false); + if (!db.isInitialized) await db.init(); + await db.notes?.init(); await db.notes?.add({ content: { type: "tiptap", data: `

${input}

` } }); - if (!db.isInitialized) await db.init(); - await db.notes?.init(); await db.sync(false, false); useNoteStore.getState().setNotes(); break; diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js index 9578ec94d..a757d34cb 100644 --- a/apps/mobile/share/share.js +++ b/apps/mobile/share/share.js @@ -26,12 +26,12 @@ import { Keyboard, Platform, SafeAreaView, + ScrollView, StatusBar, Text, TouchableOpacity, - useWindowDimensions, View, - ScrollView + useWindowDimensions } from "react-native"; import { SafeAreaProvider, @@ -45,10 +45,9 @@ import Storage from "../app/common/database/storage"; import { eSendEvent } from "../app/services/event-manager"; import { getElevation } from "../app/utils"; import { eOnLoadNote } from "../app/utils/events"; -import { sleep } from "../app/utils/time"; +import { Editor } from "./editor"; import { Search } from "./search"; import { initDatabase, useShareStore } from "./store"; -import { Editor } from "./editor"; const getLinkPreview = (url) => { return getPreviewData(url, 5000); }; @@ -315,7 +314,6 @@ const ShareView = ({ quicknote = false }) => { const onPress = async () => { setLoading(true); await initDatabase(); - await sleep(1500); if (!noteContent.current) return; if (appendNote && !db.notes.note(appendNote.id)) { useShareStore.getState().setAppendNote(null); @@ -358,7 +356,6 @@ const ShareView = ({ quicknote = false }) => { } } } - if (!db.isInitialized) await db.init(); await db.sync(false, false); await Storage.write("notesAddedFromIntent", "added"); close(); diff --git a/apps/mobile/share/store.js b/apps/mobile/share/store.js index 395b416b3..f550c4a87 100644 --- a/apps/mobile/share/store.js +++ b/apps/mobile/share/store.js @@ -29,10 +29,9 @@ import { db } from "../app/common/database"; export async function initDatabase() { if (!db.isInitialized) { - // Only load collections in database. - await db.initCollections(); - await db.notes.init(); + await db.init(); } + await db.notes.init(); } const StorageKeys = {