reimplemented triggering search from URL, fixes #385

This commit is contained in:
zadam 2023-07-15 10:59:30 +02:00
parent ac0d61e9b4
commit b3381a3b53
3 changed files with 10 additions and 2 deletions

View file

@ -117,6 +117,10 @@ export default class TabManager extends Component {
parsedFromUrl.viewScope,
parsedFromUrl.hoistedNoteId
);
} else if (parsedFromUrl.searchString) {
await appContext.triggerCommand('searchNotes', {
searchString: parsedFromUrl.searchString
});
}
}
catch (e) {

View file

@ -153,6 +153,7 @@ function parseNavigationStateFromUrl(url) {
};
let ntxId = null;
let hoistedNoteId = null;
let searchString = null;
if (paramString) {
for (const pair of paramString.split("&")) {
@ -164,6 +165,8 @@ function parseNavigationStateFromUrl(url) {
ntxId = value;
} else if (name === 'hoistedNoteId') {
hoistedNoteId = value;
} else if (name === 'searchString') {
searchString = value; // supports triggering search from URL, e.g. #?searchString=blabla
} else if (['viewMode', 'attachmentId'].includes(name)) {
viewScope[name] = value;
} else {
@ -177,7 +180,8 @@ function parseNavigationStateFromUrl(url) {
noteId: treeService.getNoteIdFromUrl(notePath),
ntxId,
hoistedNoteId,
viewScope
viewScope,
searchString
};
}

View file

@ -86,7 +86,7 @@ export default class SearchString extends AbstractSearchOption {
}
focusOnSearchDefinitionEvent() {
this.$searchString.val(appContext.lastSearchString).focus().select();
this.$searchString.val(this.$searchString.val().trim() || appContext.lastSearchString).focus().select();
this.spacedUpdate.scheduleUpdate();
}
}