TF-900 fix not correct search result when close search box
This commit is contained in:
@@ -57,6 +57,7 @@ import 'package:tmail_ui_user/features/mailbox_creator/presentation/extensions/v
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/model/mailbox_creator_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_creator/presentation/model/new_mailbox_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/remove_email_drafts_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/action/dashboard_action.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/dashboard_routes.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||
@@ -101,7 +102,7 @@ class MailboxController extends BaseMailboxController {
|
||||
jmap.State? _currentMailboxState;
|
||||
List<String> listMailboxNameAsStringExist = <String>[];
|
||||
|
||||
late Worker accountIdWorker, viewStateWorker;
|
||||
late Worker accountIdWorker, viewStateWorker, dashboardActionWorker;
|
||||
|
||||
MailboxController(
|
||||
this._getAllMailboxInteractor,
|
||||
@@ -236,6 +237,14 @@ class MailboxController extends BaseMailboxController {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
dashboardActionWorker = ever(mailboxDashBoardController.dashBoardAction, (action) {
|
||||
if(action is DashBoardAction) {
|
||||
if(action is ClearSearchEmailAction) {
|
||||
_switchBackToMailboxDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _registerSearchFocusListener() {
|
||||
@@ -252,6 +261,7 @@ class MailboxController extends BaseMailboxController {
|
||||
void _clearWorker() {
|
||||
accountIdWorker.call();
|
||||
viewStateWorker.call();
|
||||
dashboardActionWorker.call();
|
||||
}
|
||||
|
||||
void _initCollapseMailboxCategories() {
|
||||
|
||||
@@ -94,6 +94,13 @@ class EmptyTrashAction extends DashBoardAction {
|
||||
|
||||
EmptyTrashAction(this.context);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class ClearSearchEmailAction extends DashBoardAction {
|
||||
ClearSearchEmailAction();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
+5
@@ -422,6 +422,11 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
&& dashboardRoute.value == DashboardRoutes.emailDetailed;
|
||||
}
|
||||
|
||||
void clearSearchEmail() {
|
||||
dispatchAction(ClearSearchEmailAction());
|
||||
searchController.disableSearch();
|
||||
}
|
||||
|
||||
void _unSelectedMailbox() {
|
||||
selectedMailbox.value = null;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,6 @@ class SearchController extends BaseController {
|
||||
searchInputController.clear();
|
||||
cleanSearchFilter();
|
||||
searchFocus.unfocus();
|
||||
searchState.value = searchState.value.disableSearchState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/re
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
|
||||
|
||||
final MailboxDashBoardController dashBoardController;
|
||||
final ImagePaths imagePaths;
|
||||
final double maxWidth;
|
||||
|
||||
const SearchInputFormWidget({
|
||||
SearchInputFormWidget({
|
||||
Key? key,
|
||||
required this.dashBoardController,
|
||||
required this.imagePaths,
|
||||
@@ -65,6 +64,8 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
|
||||
if (query.isNotEmpty) {
|
||||
controller.saveRecentSearch(RecentSearch.now(query));
|
||||
dashBoardController.searchEmail(context, query);
|
||||
} else {
|
||||
dashBoardController.clearSearchEmail();
|
||||
}
|
||||
},
|
||||
onChanged: controller.onChangeTextSearch,
|
||||
@@ -92,6 +93,8 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
|
||||
if (keyword.isNotEmpty) {
|
||||
controller.saveRecentSearch(RecentSearch.now(keyword));
|
||||
dashBoardController.searchEmail(context, keyword);
|
||||
} else {
|
||||
dashBoardController.clearSearchEmail();
|
||||
}
|
||||
}),
|
||||
clearTextButton: buildIconWeb(
|
||||
@@ -150,7 +153,10 @@ class SearchInputFormWidget extends StatelessWidget with AppLoaderMixin {
|
||||
if (query.isNotEmpty) {
|
||||
controller.saveRecentSearch(RecentSearch.now(query));
|
||||
dashBoardController.searchEmail(context, query);
|
||||
} else {
|
||||
dashBoardController.clearSearchEmail();
|
||||
}
|
||||
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
|
||||
Reference in New Issue
Block a user