From 3d3026ed022daa185be1eefd99c1102ef32edb79 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 24 Jun 2020 20:50:19 +0300 Subject: [PATCH] Handle history when entity is deleted --- lib/redux/app/app_state.dart | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/redux/app/app_state.dart b/lib/redux/app/app_state.dart index 3666f9aed..5d4a30070 100644 --- a/lib/redux/app/app_state.dart +++ b/lib/redux/app/app_state.dart @@ -161,6 +161,9 @@ abstract class AppState implements Built { return true; }).toList(); + List get unfilteredHistoryList => + prefState.companyPrefs[uiState.selectedCompanyIndex].historyList.toList(); + bool shouldSelectEntity({EntityType entityType, List entityList}) { final entityUIState = getUIState(entityType); @@ -173,30 +176,13 @@ abstract class AppState implements Built { if ((entityUIState.selectedId ?? '').isEmpty) { return true; - } else if (historyList.isNotEmpty && - historyList.first.entityType != entityType) { + } else if (unfilteredHistoryList.isNotEmpty && + unfilteredHistoryList.first.entityType != entityType) { // check if this needs to be added to the history return null; } return false; - - /* - if (entityList.isEmpty) { - // no selection - return (entityUIState.selectedId ?? '').isNotEmpty; - } else if ((entityUIState.selectedId ?? '').isEmpty || - !entityList.contains(entityUIState.selectedId)) { - // the current selection is no longer an option - return true; - } else if (historyList.isNotEmpty && - historyList.first.entityType != entityType) { - // check if this needs to be added to the history - return null; - } - - return false; - */ } // TODO add to starter.sh