mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
remember last search in Jump To dialog when searching soon after the previous search
This commit is contained in:
parent
408ed8dbf0
commit
574b71de63
@ -6,9 +6,10 @@ const $dialog = $("#jump-to-note-dialog");
|
|||||||
const $autoComplete = $("#jump-to-note-autocomplete");
|
const $autoComplete = $("#jump-to-note-autocomplete");
|
||||||
const $showInFullTextButton = $("#show-in-full-text-button");
|
const $showInFullTextButton = $("#show-in-full-text-button");
|
||||||
|
|
||||||
export async function showDialog() {
|
let lastOpenedTs = 0;
|
||||||
$autoComplete.val('');
|
const KEEP_LAST_SEARCH_FOR_X_SECONDS = 120;
|
||||||
|
|
||||||
|
export async function showDialog() {
|
||||||
utils.openDialog($dialog);
|
utils.openDialog($dialog);
|
||||||
|
|
||||||
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true })
|
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true })
|
||||||
@ -20,7 +21,20 @@ export async function showDialog() {
|
|||||||
appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
|
appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
|
||||||
});
|
});
|
||||||
|
|
||||||
noteAutocompleteService.showRecentNotes($autoComplete);
|
// if you open the Jump To dialog soon after using it previously it can often mean that you
|
||||||
|
// actually want to search for the same thing (e.g. you opened the wrong note at first try)
|
||||||
|
// so we'll keep the content.
|
||||||
|
// if it's outside of this time limit then we assume it's a completely new search and show recent notes instead.
|
||||||
|
if (Date.now() - lastOpenedTs > KEEP_LAST_SEARCH_FOR_X_SECONDS * 1000) {
|
||||||
|
noteAutocompleteService.showRecentNotes($autoComplete);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$autoComplete
|
||||||
|
.trigger('focus')
|
||||||
|
.trigger('select');
|
||||||
|
}
|
||||||
|
|
||||||
|
lastOpenedTs = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInFullText(e) {
|
function showInFullText(e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user