Skip to content

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

mobile: fix merge conflicts for locked notes

Ammar Ahmed80328af8889a
diff --git a/apps/mobile/app/components/dialogs/vault/index.tsx b/apps/mobile/app/components/dialogs/vault/index.tsx
index 74657dde6..fd90604c2 100644
--- a/apps/mobile/app/components/dialogs/vault/index.tsx
+++ b/apps/mobile/app/components/dialogs/vault/index.tsx
@@ -417,9 +417,10 @@ export const VaultDialog: React.FC = () => {
onUnlockRef.current
) {
const password = passwordRef.current;
+ const unlock = onUnlockRef.current;
close();
- await sleep(300);
- onUnlockRef.current(note, password);
+ await sleep(500);
+ unlock(note, password);
}
} catch (e) {
takeErrorAction();
diff --git a/apps/mobile/app/components/merge-conflicts/index.tsx b/apps/mobile/app/components/merge-conflicts/index.tsx
index ec1bd298f..8798ac386 100644
--- a/apps/mobile/app/components/merge-conflicts/index.tsx
+++ b/apps/mobile/app/components/merge-conflicts/index.tsx
@@ -60,6 +60,7 @@ import { IconButton } from "../ui/icon-button";
import Seperator from "../ui/seperator";
import Paragraph from "../ui/typography/paragraph";
import { presentDialog } from "../dialog/functions";
+import { Cipher } from "@notesnook/crypto";
const MergeConflicts = () => {
const { colors } = useThemeColors();
@@ -84,12 +85,21 @@ const MergeConflicts = () => {
dateEdited: contentToSave.dateEdited
});
- const noteLocked = await db.vaults.itemExists(note);
+ const noteContent = await db.content.findByNoteId(note.id);
- if (noteLocked) {
- await db.vault.save({
- ...contentToSave,
- sessionId: `${Date.now()}`
+ if (noteContent?.locked) {
+ const selectedContent = contentToSave.conflicted
+ ? noteContent
+ : noteContent.conflicted;
+
+ await db.content.add({
+ id: note.contentId,
+ dateResolved: noteContent?.conflicted?.dateModified || Date.now(),
+ sessionId: `${Date.now()}`,
+ data: selectedContent?.data as Cipher<"base64">,
+ type: selectedContent?.type,
+ locked: true,
+ conflicted: undefined
});
} else {
await db.content.add({
@@ -138,7 +148,6 @@ const MergeConflicts = () => {
onUnlock: async (item, password) => {
if (!item || !password) return;
const currentContent = await db.content.get(item.contentId!);
-
try {
noteContent = {
...(await db.content.get(item.contentId!)),