From 22eb7d47827366399ecb791ab168e42d48938064 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 4 Jun 2023 16:50:18 +0300 Subject: [PATCH] Cancel button for client settings doesn't work #494 --- lib/redux/ui/pref_reducer.dart | 3 +++ lib/ui/app/history_drawer.dart | 14 ++++++++++---- lib/ui/app/main_screen.dart | 20 +++++++++++--------- lib/ui/app/menu_drawer.dart | 15 ++++++++++----- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/redux/ui/pref_reducer.dart b/lib/redux/ui/pref_reducer.dart index 13827622e..6a0070be1 100644 --- a/lib/redux/ui/pref_reducer.dart +++ b/lib/redux/ui/pref_reducer.dart @@ -551,6 +551,9 @@ Reducer> historyReducer = combineReducers([ TypedReducer, ViewClient>((historyList, action) => _addToHistory(historyList, HistoryRecord(id: action.clientId, entityType: EntityType.client))), + TypedReducer, ViewClientList>((historyList, + action) => + _addToHistory(historyList, HistoryRecord(entityType: EntityType.client))), TypedReducer, EditClient>((historyList, action) => _addToHistory(historyList, HistoryRecord(id: action.client.id, entityType: EntityType.client))), diff --git a/lib/ui/app/history_drawer.dart b/lib/ui/app/history_drawer.dart index 4b11014f2..abc2cdcd2 100644 --- a/lib/ui/app/history_drawer.dart +++ b/lib/ui/app/history_drawer.dart @@ -132,6 +132,8 @@ class _HistoryListTileState extends State { style: Theme.of(context).textTheme.bodySmall, ); } + } else if (history.id == null) { + title = Text(localization.lookup(history.entityType.plural)); } else { entity = state.getEntityMap(history.entityType)[history.id] as BaseEntity; @@ -241,10 +243,14 @@ class _HistoryListTileState extends State { )); break; default: - viewEntityById( - entityId: history.id, - entityType: history.entityType, - ); + if (history.id == null) { + viewEntitiesByType(entityType: history.entityType); + } else { + viewEntityById( + entityId: history.id, + entityType: history.entityType, + ); + } } }, onLongPress: entity == null diff --git a/lib/ui/app/main_screen.dart b/lib/ui/app/main_screen.dart index c1c3c1c81..c51c43625 100644 --- a/lib/ui/app/main_screen.dart +++ b/lib/ui/app/main_screen.dart @@ -274,11 +274,9 @@ class MainScreen extends StatelessWidget { ].contains(item.entityType)) { history = item; break; + } else if (item.id == null) { + history = item; } else { - if (item.id == null) { - continue; - } - final entity = state.getEntityMap(item.entityType)[item.id] as BaseEntity; if (entity == null || !entity.isActive) { @@ -314,11 +312,15 @@ class MainScreen extends StatelessWidget { )); break; default: - viewEntityById( - entityId: history.id, - entityType: history.entityType, - showError: false, - ); + if (history.id == null) { + viewEntitiesByType(entityType: history.entityType); + } else { + viewEntityById( + entityId: history.id, + entityType: history.entityType, + showError: false, + ); + } } return false; diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index 146c6c018..5bb4551fa 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -132,11 +132,16 @@ class _MenuDrawerState extends State { )); break; default: - viewEntityById( - entityId: history.id, - entityType: history.entityType, - showError: false, - ); + if (history.id == null) { + viewEntitiesByType( + entityType: history.entityType); + } else { + viewEntityById( + entityId: history.id, + entityType: history.entityType, + showError: false, + ); + } } }, icon: Icon(MdiIcons.arrowLeftCircleOutline))