From 206c006ddcf35625873a8ee634b8c67d400344a1 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Wed, 6 Dec 2023 11:18:53 +0100 Subject: [PATCH] Fix areas not refreshing after deleting, closes #541 --- app/lib/bloc/document_bloc.dart | 15 +++++++++++---- app/lib/handlers/area.dart | 1 + fastlane/metadata/android/en-US/changelogs/82.txt | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/lib/bloc/document_bloc.dart b/app/lib/bloc/document_bloc.dart index d7a0e89bc356..707710a0abd6 100644 --- a/app/lib/bloc/document_bloc.dart +++ b/app/lib/bloc/document_bloc.dart @@ -672,14 +672,21 @@ class DocumentBloc extends ReplayBloc { if (!(current.embedding?.editable ?? true)) return; final areas = List.from(current.page.areas) ..removeWhere((e) => event.areas.contains(e.name)); - final currentDocument = current.page.copyWith(areas: areas); + final currentPage = current.page.copyWith(areas: areas); + var shouldRepaint = false; for (var element in current.renderers) { if (areas.contains(element.area) && - await element.onAreaUpdate(current.data, currentDocument, null)) { - _repaint(emit); + await element.onAreaUpdate(current.data, currentPage, null)) { + shouldRepaint = true; } } - _saveState(emit, current.copyWith(page: currentDocument)); + if (shouldRepaint) { + _repaint(emit); + } + _saveState(emit, current.copyWith(page: currentPage)).then((_) { + current.currentIndexCubit.refresh( + current.data, current.assetService, currentPage, current.info); + }); }); on((event, emit) async { final current = state; diff --git a/app/lib/handlers/area.dart b/app/lib/handlers/area.dart index dcbefe47a0dd..69199bb25ea8 100644 --- a/app/lib/handlers/area.dart +++ b/app/lib/handlers/area.dart @@ -99,6 +99,7 @@ class AreaHandler extends Handler { )); } if (name == null) return; + currentRect = null; context.getDocumentBloc().add(AreasCreated([ Area( width: rect.width, diff --git a/fastlane/metadata/android/en-US/changelogs/82.txt b/fastlane/metadata/android/en-US/changelogs/82.txt index 90887c4a7b91..c08c57be84ba 100644 --- a/fastlane/metadata/android/en-US/changelogs/82.txt +++ b/fastlane/metadata/android/en-US/changelogs/82.txt @@ -3,6 +3,7 @@ * Fix zoom usable if hidden ([#538](https://github.com/LinwoodDev/Butterfly/issues/538)) * Fix full screen menu item ([#535](https://github.com/LinwoodDev/Butterfly/issues/535)) * Fix selecting small areas ([#543](https://github.com/LinwoodDev/Butterfly/issues/543)) +* Fix areas not refreshing after deleting ([#541](https://github.com/LinwoodDev/Butterfly/issues/541)) * Fix tool not selected when added View all changes in the blog: https://linwood.dev/butterfly/2.0.0-rc.1 \ No newline at end of file