remember last used search in boards
This commit is contained in:
Vendored
+18
-5
@@ -2100,8 +2100,8 @@
|
|||||||
TaskViewModel.getStringsForFilter,
|
TaskViewModel.getStringsForFilter,
|
||||||
this.searchSuggestions
|
this.searchSuggestions
|
||||||
);
|
);
|
||||||
this.searchViewModel.appliedQuery.subscribe((newQuery) => {
|
this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => {
|
||||||
this.storeSearchTerm(newQuery);
|
this.handleNewSearch(newQuery);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
storageModel;
|
storageModel;
|
||||||
@@ -2132,6 +2132,9 @@
|
|||||||
getPreviousSearchesPath = () => {
|
getPreviousSearchesPath = () => {
|
||||||
return [...this.getBasePath(), "previous-searches" /* PreviousSearches */];
|
return [...this.getBasePath(), "previous-searches" /* PreviousSearches */];
|
||||||
};
|
};
|
||||||
|
getLastSearchPath = () => {
|
||||||
|
return [...this.getBasePath(), "last-search" /* LastSearch */];
|
||||||
|
};
|
||||||
// settings
|
// settings
|
||||||
saveSettings = () => {
|
saveSettings = () => {
|
||||||
const newBoardInfoFileContent = BoardsAndTasksModel.createBoardInfoFileContent(
|
const newBoardInfoFileContent = BoardsAndTasksModel.createBoardInfoFileContent(
|
||||||
@@ -2174,12 +2177,17 @@
|
|||||||
if (lastUsedView == null) return;
|
if (lastUsedView == null) return;
|
||||||
this.selectedPage.value = lastUsedView;
|
this.selectedPage.value = lastUsedView;
|
||||||
};
|
};
|
||||||
storeSearchTerm = (searchTerm) => {
|
handleNewSearch = (searchTerm) => {
|
||||||
const path = [...this.getPreviousSearchesPath(), searchTerm];
|
const suggestionPath = [
|
||||||
this.storageModel.write(path, "");
|
...this.getPreviousSearchesPath(),
|
||||||
|
searchTerm
|
||||||
|
];
|
||||||
|
this.storageModel.write(suggestionPath, "");
|
||||||
if (!this.searchSuggestions.value.has(searchTerm)) {
|
if (!this.searchSuggestions.value.has(searchTerm)) {
|
||||||
this.searchSuggestions.add(searchTerm);
|
this.searchSuggestions.add(searchTerm);
|
||||||
}
|
}
|
||||||
|
const lastSearchPath = this.getLastSearchPath();
|
||||||
|
this.storageModel.write(lastSearchPath, searchTerm);
|
||||||
};
|
};
|
||||||
// view
|
// view
|
||||||
showTask = (taskFileContent) => {
|
showTask = (taskFileContent) => {
|
||||||
@@ -2254,6 +2262,11 @@
|
|||||||
const dirPath = this.getPreviousSearchesPath();
|
const dirPath = this.getPreviousSearchesPath();
|
||||||
const searches = this.storageModel.list(dirPath);
|
const searches = this.storageModel.list(dirPath);
|
||||||
this.searchSuggestions.add(...searches);
|
this.searchSuggestions.add(...searches);
|
||||||
|
const lastSearchPath = this.getLastSearchPath();
|
||||||
|
const lastSearch = this.storageModel.read(lastSearchPath);
|
||||||
|
if (lastSearch) {
|
||||||
|
this.searchViewModel.search(lastSearch);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
loadData = () => {
|
loadData = () => {
|
||||||
this.restoreLastUsedView();
|
this.restoreLastUsedView();
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
return [...this.getBasePath(), BoardViewModelSubPath.PreviousSearches];
|
return [...this.getBasePath(), BoardViewModelSubPath.PreviousSearches];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getLastSearchPath = (): string[] => {
|
||||||
|
return [...this.getBasePath(), BoardViewModelSubPath.LastSearch];
|
||||||
|
};
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
saveSettings = (): void => {
|
saveSettings = (): void => {
|
||||||
const newBoardInfoFileContent: BoardInfoFileContent =
|
const newBoardInfoFileContent: BoardInfoFileContent =
|
||||||
@@ -106,12 +110,18 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
this.selectedPage.value = lastUsedView as BoardPageType;
|
this.selectedPage.value = lastUsedView as BoardPageType;
|
||||||
};
|
};
|
||||||
|
|
||||||
storeSearchTerm = (searchTerm: string): void => {
|
handleNewSearch = (searchTerm: string): void => {
|
||||||
const path: string[] = [...this.getPreviousSearchesPath(), searchTerm];
|
const suggestionPath: string[] = [
|
||||||
this.storageModel.write(path, "");
|
...this.getPreviousSearchesPath(),
|
||||||
|
searchTerm,
|
||||||
|
];
|
||||||
|
this.storageModel.write(suggestionPath, "");
|
||||||
if (!this.searchSuggestions.value.has(searchTerm)) {
|
if (!this.searchSuggestions.value.has(searchTerm)) {
|
||||||
this.searchSuggestions.add(searchTerm);
|
this.searchSuggestions.add(searchTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lastSearchPath: string[] = this.getLastSearchPath();
|
||||||
|
this.storageModel.write(lastSearchPath, searchTerm);
|
||||||
};
|
};
|
||||||
|
|
||||||
// view
|
// view
|
||||||
@@ -205,6 +215,12 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
const dirPath: string[] = this.getPreviousSearchesPath();
|
const dirPath: string[] = this.getPreviousSearchesPath();
|
||||||
const searches: string[] = this.storageModel.list(dirPath);
|
const searches: string[] = this.storageModel.list(dirPath);
|
||||||
this.searchSuggestions.add(...searches);
|
this.searchSuggestions.add(...searches);
|
||||||
|
|
||||||
|
const lastSearchPath: string[] = this.getLastSearchPath();
|
||||||
|
const lastSearch: string | null = this.storageModel.read(lastSearchPath);
|
||||||
|
if (lastSearch) {
|
||||||
|
this.searchViewModel.search(lastSearch);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData = (): void => {
|
loadData = (): void => {
|
||||||
@@ -264,8 +280,8 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
TaskViewModel.getStringsForFilter,
|
TaskViewModel.getStringsForFilter,
|
||||||
this.searchSuggestions
|
this.searchSuggestions
|
||||||
);
|
);
|
||||||
this.searchViewModel.appliedQuery.subscribe((newQuery) => {
|
this.searchViewModel.appliedQuery.subscribeSilent((newQuery) => {
|
||||||
this.storeSearchTerm(newQuery);
|
this.handleNewSearch(newQuery);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,6 +289,7 @@ export default class BoardViewModel extends TaskContainingPageViewModel {
|
|||||||
export enum BoardViewModelSubPath {
|
export enum BoardViewModelSubPath {
|
||||||
LastUsedView = "last-used-view",
|
LastUsedView = "last-used-view",
|
||||||
PreviousSearches = "previous-searches",
|
PreviousSearches = "previous-searches",
|
||||||
|
LastSearch = "last-search",
|
||||||
}
|
}
|
||||||
|
|
||||||
// types
|
// types
|
||||||
|
|||||||
Reference in New Issue
Block a user