Compare commits

...

4 Commits

Author SHA1 Message Date
Ammar Ahmed
2febd09613 Merge branch 'master' into fix/sync-quick-notes
Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
2023-04-26 15:13:27 +05:00
ammarahm-ed
91138f4911 mobile: ensure full db init when sync is required 2023-04-26 15:12:29 +05:00
Ammar Ahmed
8a138d960d Update apps/mobile/app/services/notifications.ts
Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
Signed-off-by: Ammar Ahmed <40239442+ammarahm-ed@users.noreply.github.com>
2023-04-26 14:57:06 +05:00
ammarahm-ed
59442b9107 mobile: sync quick notes 2023-04-26 09:51:24 +05:00
3 changed files with 8 additions and 9 deletions

View File

@@ -203,14 +203,15 @@ const onEvent = async ({ type, detail }: Event) => {
reply_button_text: "Take note", reply_button_text: "Take note",
reply_placeholder_text: "Write something..." reply_placeholder_text: "Write something..."
}); });
await initDatabase(false); if (!db.isInitialized) await db.init();
await db.notes?.init();
await db.notes?.add({ await db.notes?.add({
content: { content: {
type: "tiptap", type: "tiptap",
data: `<p>${input} </p>` data: `<p>${input} </p>`
} }
}); });
await db.notes?.init(); await db.sync(false, false);
useNoteStore.getState().setNotes(); useNoteStore.getState().setNotes();
break; break;
} }

View File

@@ -26,12 +26,12 @@ import {
Keyboard, Keyboard,
Platform, Platform,
SafeAreaView, SafeAreaView,
ScrollView,
StatusBar, StatusBar,
Text, Text,
TouchableOpacity, TouchableOpacity,
useWindowDimensions,
View, View,
ScrollView useWindowDimensions
} from "react-native"; } from "react-native";
import { import {
SafeAreaProvider, SafeAreaProvider,
@@ -45,10 +45,9 @@ import Storage from "../app/common/database/storage";
import { eSendEvent } from "../app/services/event-manager"; import { eSendEvent } from "../app/services/event-manager";
import { getElevation } from "../app/utils"; import { getElevation } from "../app/utils";
import { eOnLoadNote } from "../app/utils/events"; import { eOnLoadNote } from "../app/utils/events";
import { sleep } from "../app/utils/time"; import { Editor } from "./editor";
import { Search } from "./search"; import { Search } from "./search";
import { initDatabase, useShareStore } from "./store"; import { initDatabase, useShareStore } from "./store";
import { Editor } from "./editor";
const getLinkPreview = (url) => { const getLinkPreview = (url) => {
return getPreviewData(url, 5000); return getPreviewData(url, 5000);
}; };
@@ -315,7 +314,6 @@ const ShareView = ({ quicknote = false }) => {
const onPress = async () => { const onPress = async () => {
setLoading(true); setLoading(true);
await initDatabase(); await initDatabase();
await sleep(1500);
if (!noteContent.current) return; if (!noteContent.current) return;
if (appendNote && !db.notes.note(appendNote.id)) { if (appendNote && !db.notes.note(appendNote.id)) {
useShareStore.getState().setAppendNote(null); useShareStore.getState().setAppendNote(null);
@@ -358,6 +356,7 @@ const ShareView = ({ quicknote = false }) => {
} }
} }
} }
await db.sync(false, false);
await Storage.write("notesAddedFromIntent", "added"); await Storage.write("notesAddedFromIntent", "added");
close(); close();
setLoading(false); setLoading(false);

View File

@@ -29,8 +29,7 @@ import { db } from "../app/common/database";
export async function initDatabase() { export async function initDatabase() {
if (!db.isInitialized) { if (!db.isInitialized) {
// Only load collections in database. await db.init();
await db.initCollections();
} }
await db.notes.init(); await db.notes.init();
} }