mobile: fix unlocking note with biometrics

This commit is contained in:
Ammar Ahmed
2025-02-04 16:54:33 +05:00
parent 275b285a8b
commit b652071703
5 changed files with 21 additions and 22 deletions

View File

@@ -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({

View File

@@ -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);

View File

@@ -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(

View File

@@ -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) {

View File

@@ -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
}}