Skip to content

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

mobile: fix unlocking note with biometrics

Ammar Ahmed5dd298ee86a3
diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx
index 95ce63715..0b939244c 100755
--- a/apps/mobile/app/screens/editor/index.tsx
+++ b/apps/mobile/app/screens/editor/index.tsx
@@ -248,14 +248,13 @@ const useLockedNoteHandler = () => {
);
eSendEvent(eOnLoadNote, {
- item: note
- });
-
- useTabStore.getState().updateTab(tabRef.current.id, {
- session: {
- locked: false
- }
+ item: note,
+ refresh: true
});
+ } else {
+ if (tabRef.current && tabRef.current.session?.locked) {
+ editorController.current?.commands.focusPassInput();
+ }
}
} catch (e) {
console.error(e);
@@ -310,12 +309,8 @@ const useLockedNoteHandler = () => {
}
}
eSendEvent(eOnLoadNote, {
- item: note
- });
- useTabStore.getState().updateTab(tabRef.current.id, {
- session: {
- locked: false
- }
+ item: note,
+ refresh: true
});
} catch (e) {
ToastManager.show({
diff --git a/apps/mobile/app/screens/editor/tiptap/commands.ts b/apps/mobile/app/screens/editor/tiptap/commands.ts
index 50ab1429b..5119c8232 100644
--- a/apps/mobile/app/screens/editor/tiptap/commands.ts
+++ b/apps/mobile/app/screens/editor/tiptap/commands.ts
@@ -90,8 +90,14 @@ class Commands {
const locked = useTabStore.getState().getTab(tabId)?.session?.locked;
if (Platform.OS === "android") {
- //this.ref.current?.requestFocus();
setTimeout(async () => {
+ if (
+ locked &&
+ useTabStore.getState().biometryAvailable &&
+ useTabStore.getState().biometryEnrolled
+ )
+ return;
+
if (!this.ref) return;
textInput.current?.focus();
await this.sendCommand("focus", tabId, locked);
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index 04750137c..bef1acfcf 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -501,6 +501,7 @@ export const useEditor = (
blockId?: string;
session?: TabSessionItem;
newTab?: boolean;
+ refresh?: boolean;
}) => {
loadNoteMutex.runExclusive(async () => {
if (!event) return;
@@ -574,11 +575,10 @@ export const useEditor = (
? event.tabId
: useTabStore.getState().currentTab;
- console.log(tabId === useTabStore.getState().currentTab);
-
// Check if tab needs to be refreshed.
if (!event.newTab) {
if (
+ !event.refresh &&
tabId &&
event.item.id === useTabStore.getState().getNoteIdForTab(tabId) &&
!localTabState.current?.needsRefresh(
diff --git a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts b/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts
index 55a638e62..3166eedba 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-tab-store.ts
@@ -358,8 +358,8 @@ export const useTabStore = create<TabStore>(
if (note) {
const isLocked = await db.vaults.itemExists(note);
+ session.noteLocked = isLocked;
session.locked = isLocked;
- session.noteLocked = isLocked && !session?.noteLocked;
session.readonly = note.readonly;
} else if (session.noteId) {
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index ef9b3ba90..874f19f77 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -556,7 +556,7 @@ const Tiptap = ({
</>
)}
- {controller.loading || tab.session?.noteLocked ? (
+ {controller.loading || tab.session?.locked ? (
<div
style={{
width: "100%",
@@ -568,10 +568,8 @@ const Tiptap = ({
paddingLeft: 12,
display: "flex",
flexDirection: "column",
- alignItems: tab.session?.noteLocked ? "center" : "flex-start",
- justifyContent: tab.session?.noteLocked
- ? "center"
- : "flex-start",
+ alignItems: "center",
+ justifyContent: "center",
boxSizing: "border-box",
rowGap: 10
}}