diff --git a/dist/index.js b/dist/index.js index 4da9a009..0dfbfe03 100644 --- a/dist/index.js +++ b/dist/index.js @@ -426,7 +426,7 @@ function getLocalStorageItemAndClear(key) { const value = localStorage.getItem(key); localStorage.removeItem(key); - console.log(localStorage.getItem(key)); + if (value != null) localStorage.setItem(`_${key}`, value); return value; } function stringify(data) { @@ -2049,7 +2049,7 @@ }; applySearch = () => { this.appliedQuery.value = this.searchInput.value; - console.log("applying search"); + console.trace("applying search"); this.matchingObjects.clear(); for (const object of this.allObjects.value.values()) { const doesMatch = this.checkDoesMatchSearch(object); @@ -2124,6 +2124,7 @@ this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => { this.handleNewSearch(newQuery); }); + this.restoreSearch(); } storageModel; boardsAndTasksModel; @@ -2282,9 +2283,11 @@ const dirPath = this.getPreviousSearchesPath(); const searches = this.storageModel.list(dirPath); this.coreViewModel.boardSearchSuggestions.add(...searches); + }; + restoreSearch = () => { const lastSearchPath = this.getLastSearchPath(); const lastSearch = this.storageModel.read(lastSearchPath); - if (lastSearch) { + if (lastSearch != null) { this.searchViewModel.search(lastSearch); } }; diff --git a/src/Model/Utility/utility.ts b/src/Model/Utility/utility.ts index 14b9d073..b10b6b55 100644 --- a/src/Model/Utility/utility.ts +++ b/src/Model/Utility/utility.ts @@ -223,7 +223,7 @@ export class IndexManager { export function getLocalStorageItemAndClear(key: string): string | null { const value: string | null = localStorage.getItem(key); localStorage.removeItem(key); - console.log(localStorage.getItem(key)); + if (value != null) localStorage.setItem(`_${key}`, value); return value; } diff --git a/src/ViewModel/Pages/boardViewModel.ts b/src/ViewModel/Pages/boardViewModel.ts index 21158ddf..bef593cf 100644 --- a/src/ViewModel/Pages/boardViewModel.ts +++ b/src/ViewModel/Pages/boardViewModel.ts @@ -214,10 +214,12 @@ export default class BoardViewModel extends TaskContainingPageViewModel { const dirPath: string[] = this.getPreviousSearchesPath(); const searches: string[] = this.storageModel.list(dirPath); this.coreViewModel.boardSearchSuggestions.add(...searches); + }; + restoreSearch = (): void => { const lastSearchPath: string[] = this.getLastSearchPath(); const lastSearch: string | null = this.storageModel.read(lastSearchPath); - if (lastSearch) { + if (lastSearch != null) { this.searchViewModel.search(lastSearch); } }; @@ -282,6 +284,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel { this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => { this.handleNewSearch(newQuery); }); + this.restoreSearch(); } } diff --git a/src/ViewModel/Utility/searchViewModel.ts b/src/ViewModel/Utility/searchViewModel.ts index 5ea86dd1..156742c1 100644 --- a/src/ViewModel/Utility/searchViewModel.ts +++ b/src/ViewModel/Utility/searchViewModel.ts @@ -28,7 +28,7 @@ export default class SearchViewModel { applySearch = (): void => { this.appliedQuery.value = this.searchInput.value; - console.log("applying search"); + console.trace("applying search"); this.matchingObjects.clear(); for (const object of this.allObjects.value.values()) {