diff --git a/CHANGELOG.md b/CHANGELOG.md index ac75e38d..b1953642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 12.4.3 +- **FIX**(state-manager): Update activeFilters and activeTuneAdjustments to directly use historyPointer. + ## 12.4.2 - **FEAT**(state-manager): Add `replaceHistory()` to replace an existing history entry in the stack (current pointer by default, or a custom index). diff --git a/lib/features/main_editor/services/state_manager.dart b/lib/features/main_editor/services/state_manager.dart index b8ad25d0..1241ce6e 100644 --- a/lib/features/main_editor/services/state_manager.dart +++ b/lib/features/main_editor/services/state_manager.dart @@ -106,19 +106,9 @@ class StateManager { void updateActiveItems() { var activeHistory = _stateHistory.getRange(0, _historyPointer + 1); - activeFilters = activeHistory - .lastWhere( - (item) => item.filters.isNotEmpty, - orElse: EditorStateHistory.new, - ) - .filters; - - activeTuneAdjustments = activeHistory - .lastWhere( - (item) => item.tuneAdjustments.isNotEmpty, - orElse: EditorStateHistory.new, - ) - .tuneAdjustments; + activeFilters = _stateHistory[historyPointer].filters; + + activeTuneAdjustments = _stateHistory[historyPointer].tuneAdjustments; activeLayers = _stateHistory[historyPointer].layers; diff --git a/pubspec.yaml b/pubspec.yaml index 21a0ba4c..f6952097 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pro_image_editor description: "A Flutter image editor: Seamlessly enhance your images with user-friendly editing features." -version: 12.4.2 +version: 12.4.3 homepage: https://github.com/hm21/pro_image_editor/ repository: https://github.com/hm21/pro_image_editor/ documentation: https://github.com/hm21/pro_image_editor/ diff --git a/test/shared/services/import_export/import_export_test.dart b/test/shared/services/import_export/import_export_test.dart index 9a1c490a..c8a87a31 100644 --- a/test/shared/services/import_export/import_export_test.dart +++ b/test/shared/services/import_export/import_export_test.dart @@ -149,7 +149,7 @@ void main() { editor, onAfterImport: () { editor.addHistory(filters: const []); - expect(editor.stateManager.activeFilters.allMatrices.length, 1); + expect(editor.stateManager.activeFilters.allMatrices.length, 0); }, ); @@ -179,7 +179,7 @@ void main() { editor, onAfterImport: () { editor.addHistory(tuneAdjustments: []); - expect(editor.stateManager.activeTuneAdjustments.length, 1); + expect(editor.stateManager.activeTuneAdjustments.length, 0); }, );