TF-3767 Use TupleKey to save recent search for each account

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-06-11 12:13:28 +07:00
committed by Dat H. Pham
parent 42fbb01847
commit bce9620ac5
13 changed files with 262 additions and 65 deletions
@@ -119,7 +119,21 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
padding: const EdgeInsets.only(bottom: 16),
child: loadingWidget
),
fetchRecentActionCallback: _searchController.getAllRecentSearchAction,
fetchRecentActionCallback: (pattern) {
final accountId = _dashBoardController.accountId.value;
final userName = _dashBoardController.sessionCurrent?.username;
if (accountId == null || userName == null) {
logError('SearchInputFormWidget::fetchRecentActionCallback: accountId or userName is null');
return <RecentSearch>[];
} else {
return _searchController.getAllRecentSearchAction(
accountId,
userName,
pattern,
);
}
},
itemRecentBuilder: (context, recent) => RecentSearchItemTileWidget(recent),
onRecentSelected: _invokeSelectRecentItem,
suggestionsCallback: _dashBoardController.quickSearchEmails,
@@ -143,7 +157,7 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
_searchController.enableSearch();
if (queryString.isNotEmpty) {
_searchController.saveRecentSearch(RecentSearch.now(queryString));
_saveRecentSearch(queryString);
}
if (queryString.isNotEmpty || _searchController.listFilterOnSuggestionForm.isNotEmpty) {
@@ -157,6 +171,22 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
}
}
void _saveRecentSearch(String queryString) {
final accountId = _dashBoardController.accountId.value;
final userName = _dashBoardController.sessionCurrent?.username;
if (accountId == null || userName == null) {
logError('SearchInputFormWidget::_saveRecentSearch: accountId or userName is null');
return;
}
_searchController.saveRecentSearch(
accountId,
userName,
RecentSearch.now(queryString),
);
}
void _invokeSelectSuggestionItem(PresentationEmail presentationEmail) {
_dashBoardController.dispatchAction(
OpenEmailDetailedFromSuggestionQuickSearchAction(