From 644a0ad2fa891569906d06c03dd71b0db7291b3a Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Sat, 27 Jul 2024 15:31:45 +0200 Subject: [PATCH] move board search suggestions to CoreViewModel --- dist/index.js | 12 +++++++----- src/ViewModel/Global/coreViewModel.ts | 4 ++++ src/ViewModel/Pages/boardViewModel.ts | 9 ++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 766dbd63..68575d8d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2104,7 +2104,7 @@ this.taskViewModels, this.filteredTaskViewModels, TaskViewModel.getStringsForFilter, - this.searchSuggestions + this.coreViewModel.boardSearchSuggestions ); this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => { this.handleNewSearch(newQuery); @@ -2127,7 +2127,6 @@ isPresentingFilterModal = new State(false); searchViewModel; filteredTaskViewModels = new ListState(); - searchSuggestions = new ListState(); // paths getBasePath = () => { return [...this.taskPageViewModel.getBoardViewPath(this.boardInfo.fileId)]; @@ -2189,8 +2188,8 @@ searchTerm ]; this.storageModel.write(suggestionPath, ""); - if (!this.searchSuggestions.value.has(searchTerm)) { - this.searchSuggestions.add(searchTerm); + if (!this.coreViewModel.boardSearchSuggestions.value.has(searchTerm)) { + this.coreViewModel.boardSearchSuggestions.add(searchTerm); } const lastSearchPath = this.getLastSearchPath(); this.storageModel.write(lastSearchPath, searchTerm); @@ -2267,7 +2266,7 @@ loadSearchSuggestions = () => { const dirPath = this.getPreviousSearchesPath(); const searches = this.storageModel.list(dirPath); - this.searchSuggestions.add(...searches); + this.coreViewModel.boardSearchSuggestions.add(...searches); const lastSearchPath = this.getLastSearchPath(); const lastSearch = this.storageModel.read(lastSearchPath); if (lastSearch) { @@ -4363,7 +4362,10 @@ // src/ViewModel/Global/coreViewModel.ts var CoreViewModel = class { + // drag&drop draggedObject = new State(void 0); + // suggestions + boardSearchSuggestions = new ListState(); }; // src/View/Components/chatEntry.tsx diff --git a/src/ViewModel/Global/coreViewModel.ts b/src/ViewModel/Global/coreViewModel.ts index b13e6582..5f79087d 100644 --- a/src/ViewModel/Global/coreViewModel.ts +++ b/src/ViewModel/Global/coreViewModel.ts @@ -1,5 +1,9 @@ import * as React from "bloatless-react"; export default class CoreViewModel { + // drag&drop draggedObject: React.State = new React.State(undefined); + + // suggestions + boardSearchSuggestions: React.ListState = new React.ListState(); } diff --git a/src/ViewModel/Pages/boardViewModel.ts b/src/ViewModel/Pages/boardViewModel.ts index ea9ffc79..21158ddf 100644 --- a/src/ViewModel/Pages/boardViewModel.ts +++ b/src/ViewModel/Pages/boardViewModel.ts @@ -39,7 +39,6 @@ export default class BoardViewModel extends TaskContainingPageViewModel { searchViewModel: SearchViewModel; filteredTaskViewModels: React.ListState = new React.ListState(); - searchSuggestions: React.ListState = new React.ListState(); // paths getBasePath = (): string[] => { @@ -116,8 +115,8 @@ export default class BoardViewModel extends TaskContainingPageViewModel { searchTerm, ]; this.storageModel.write(suggestionPath, ""); - if (!this.searchSuggestions.value.has(searchTerm)) { - this.searchSuggestions.add(searchTerm); + if (!this.coreViewModel.boardSearchSuggestions.value.has(searchTerm)) { + this.coreViewModel.boardSearchSuggestions.add(searchTerm); } const lastSearchPath: string[] = this.getLastSearchPath(); @@ -214,7 +213,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel { loadSearchSuggestions = (): void => { const dirPath: string[] = this.getPreviousSearchesPath(); const searches: string[] = this.storageModel.list(dirPath); - this.searchSuggestions.add(...searches); + this.coreViewModel.boardSearchSuggestions.add(...searches); const lastSearchPath: string[] = this.getLastSearchPath(); const lastSearch: string | null = this.storageModel.read(lastSearchPath); @@ -278,7 +277,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel { this.taskViewModels, this.filteredTaskViewModels, TaskViewModel.getStringsForFilter, - this.searchSuggestions + this.coreViewModel.boardSearchSuggestions ); this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => { this.handleNewSearch(newQuery);