A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: allow lock-unlock a note even if it's not in any vault (#9508)
Ammar Ahmede934ef7ffd95
diff --git a/apps/mobile/app/components/dialogs/vault/index.tsx b/apps/mobile/app/components/dialogs/vault/index.tsxindex 74657dde6..5a4e5fc51 100644--- a/apps/mobile/app/components/dialogs/vault/index.tsx+++ b/apps/mobile/app/components/dialogs/vault/index.tsx@@ -56,7 +56,12 @@ import Seperator from "../../ui/seperator";import Paragraph from "../../ui/typography/paragraph";import { strings } from "@notesnook/intl";import { DefaultAppStyles } from "../../../utils/styles";-import { Note, NoteContent, VAULT_ERRORS } from "@notesnook/core";+import {+ isEncryptedContent,+ Note,+ NoteContent,+ VAULT_ERRORS+} from "@notesnook/core";import { useThemeColors } from "@notesnook/theme";export const VaultDialog: React.FC = () => {@@ -109,9 +114,17 @@ export const VaultDialog: React.FC = () => {const biometry = await BiometricService.isBiometryAvailable();const available = !!biometry;const fingerprint = await BiometricService.hasInternetCredentials();- const noteLocked = data.item- ? await db.vaults.itemExists(data.item)- : false;++ if (data.item) {+ const locked = await db.vaults.itemExists(data.item);+ noteLockedRef.current = locked;+ if (!locked) {+ const content = await db.content.findByNoteId(data.item!.id);+ if (content && isEncryptedContent(content)) {+ noteLockedRef.current = true;+ }+ }+ }// Set refsnoteRef.current = data.item;@@ -122,7 +135,6 @@ export const VaultDialog: React.FC = () => {positiveButtonTypeRef.current = data.positiveButtonType || "transparent";customActionTitleRef.current = data.customActionTitle || null;customActionParagraphRef.current = data.customActionParagraph || null;- noteLockedRef.current = noteLocked;onUnlockRef.current = data.onUnlock;requestTypeRef.current = data.requestType;diff --git a/apps/mobile/app/hooks/use-actions.tsx b/apps/mobile/app/hooks/use-actions.tsxindex f2aec438a..25e6c0afa 100644--- a/apps/mobile/app/hooks/use-actions.tsx+++ b/apps/mobile/app/hooks/use-actions.tsx@@ -21,6 +21,7 @@ import { isFeatureAvailable, useAreFeaturesAvailable } from "@notesnook/common";import {Color,createInternalLink,+ isEncryptedContent,Item,ItemReference,Note,@@ -221,7 +222,15 @@ export const useActions = ({useEffect(() => {if (item.type === "note") {- db.vaults.itemExists(item).then((locked) => setLocked(locked));+ db.vaults.itemExists(item).then(async (locked) => {+ setLocked(locked);+ if (!locked) {+ const content = await db.content.findByNoteId(item.id);+ if (content && isEncryptedContent(content)) {+ setLocked(true);+ }+ }+ });}}, [item]);diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.tsindex 178cafe90..030c03534 100644--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts@@ -487,6 +487,17 @@ export const useEditor = (};} else if (note.contentId) {const rawContent = await db.content?.get(note.contentId);++ if (rawContent && isEncryptedContent(rawContent)) {+ useTabStore.getState().updateTab(useTabStore.getState().currentTab, {+ session: {+ noteLocked: true,+ locked: true+ }+ });+ return;+ }+if (rawContent && !isDeleted(rawContent) && !rawContent.locked) {currentContents.current[note.id] = {data: rawContent.data,