Skip to content

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

mobile: pass match id when opening search result snippet

kashaf-ansari-dev4bffb1c1c014
diff --git a/apps/mobile/app/components/list-items/search-result/index.tsx b/apps/mobile/app/components/list-items/search-result/index.tsx
index 46ca1d1a3..a5dfa5b22 100644
--- a/apps/mobile/app/components/list-items/search-result/index.tsx
+++ b/apps/mobile/app/components/list-items/search-result/index.tsx
@@ -43,7 +43,7 @@ export const SearchResult = (props: SearchResultProps) => {
(state) => state.settings.searchListMode === "compact"
);
- const openNote = async (index?: number) => {
+ const openNote = async (target?: number | string) => {
const note = await db.notes.note(props.item.id);
eSendEvent(eOnLoadNote, {
item: {
@@ -55,7 +55,7 @@ export const SearchResult = (props: SearchResultProps) => {
}
: undefined
},
- searchResultIndex: index
+ searchResultIndex: target
});
fluidTabsRef.current?.goToPage("editor");
};
@@ -159,7 +159,8 @@ export const SearchResult = (props: SearchResultProps) => {
for (let i = 0; i < index; i++) {
activeIndex += props.item.content[i].length;
}
- openNote(activeIndex);
+ const target = content[0]?.id ?? activeIndex;
+ openNote(target);
}}
>
<Paragraph>
diff --git a/apps/mobile/app/screens/editor/tiptap/commands.ts b/apps/mobile/app/screens/editor/tiptap/commands.ts
index 21c3e8821..b385dadb9 100644
--- a/apps/mobile/app/screens/editor/tiptap/commands.ts
+++ b/apps/mobile/app/screens/editor/tiptap/commands.ts
@@ -240,7 +240,7 @@ class Commands {
return this.sendCommand("scrollIntoViewById", id, tabId);
};
- scrollToSearchResult = (index: number) => {
+ scrollToSearchResult = (index: number | string) => {
const tabId = useTabStore.getState().currentTab;
return this.sendCommand("scrollToSearchResult", index, tabId);
};
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index e278870c9..53f3a3a1e 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -559,7 +559,7 @@ export const useEditor = (
session?: TabSessionItem;
newTab?: boolean;
refresh?: boolean;
- searchResultIndex?: number;
+ searchResultIndex?: number | string;
loadedFromEditor?: boolean;
}) => {
loadNoteMutex.runExclusive(async () => {