From 045a933f7ceae3bc2616cf5d5d6284060432eebb Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Thu, 9 Jan 2025 22:55:59 +0100 Subject: [PATCH] Fix utilities state reset after undo --- app/lib/bloc/document_bloc.dart | 6 ------ app/lib/cubits/current_index.dart | 3 ++- app/lib/views/edit.dart | 5 ----- metadata/en-US/changelogs/128.txt | 6 +++++- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/lib/bloc/document_bloc.dart b/app/lib/bloc/document_bloc.dart index 238d85a58301..f8e4d2c9015c 100644 --- a/app/lib/bloc/document_bloc.dart +++ b/app/lib/bloc/document_bloc.dart @@ -1069,13 +1069,7 @@ class DocumentBloc extends ReplayBloc { final current = state; if (current is! DocumentLoaded) return; final cubit = current.currentIndexCubit; - final document = current.data; - final page = current.page; - final assetService = current.assetService; cubit.setSaveState(saved: SaveState.saved); - final tool = UtilitiesRenderer(cubit.state.utilitiesState); - await tool.setup(document, assetService, page); - cubit.unbake(tool: tool); cubit.loadElements(current); cubit.init(this); } diff --git a/app/lib/cubits/current_index.dart b/app/lib/cubits/current_index.dart index d842fb7567a1..76b3ddff3d73 100644 --- a/app/lib/cubits/current_index.dart +++ b/app/lib/cubits/current_index.dart @@ -737,7 +737,8 @@ class CurrentIndexCubit extends Cubit { final backgrounds = page.backgrounds.map(Renderer.fromInstance).toList(); await Future.wait(backgrounds .map((e) async => await e.setup(document, assetService, page))); - final utilities = UtilitiesRenderer(state.settingsCubit.state.utilities); + final utilities = UtilitiesRenderer( + state.settingsCubit.state.utilities, state.viewOption); await utilities.setup( docState.data, docState.assetService, diff --git a/app/lib/views/edit.dart b/app/lib/views/edit.dart index 97b8a55c4f23..0998c097264b 100644 --- a/app/lib/views/edit.dart +++ b/app/lib/views/edit.dart @@ -82,11 +82,6 @@ class _EditToolbarState extends State { height: direction == Axis.horizontal ? fullSize : null, width: direction == Axis.horizontal ? null : fullSize, child: BlocBuilder( - buildWhen: (previous, current) => - previous is! DocumentLoadSuccess || - current is! DocumentLoadSuccess || - previous.tool != current.tool || - previous.info.tools != current.info.tools, builder: (context, state) { if (state is! DocumentLoadSuccess) return Container(); final tools = state.info.tools; diff --git a/metadata/en-US/changelogs/128.txt b/metadata/en-US/changelogs/128.txt index 277c6d7a0614..aabacadd7ca4 100644 --- a/metadata/en-US/changelogs/128.txt +++ b/metadata/en-US/changelogs/128.txt @@ -1,12 +1,16 @@ This is a hotfix update, cherry picking some important fixes from the last 2.3.0-beta.0 nightly release. * Add error boundaries for corrupted files +* Fix export button in data settings not working +* Fix utilties state resetted after undo + +Cherry picks: * Fix default stroke width ([#779](https://github.com/LinwoodDev/Butterfly/issues/779)) * Fix svg export shows wrong initial preset * Fix capture thumbnail uses wrong position * Fix zoom slider is not centered * Fix shape detection list tile not clickable * Fix corrupting files when saving ([#777](https://github.com/LinwoodDev/Butterfly/issues/777)) -* Fix export button in data settings not working +* Fix action tools not updating Read more here: https://linwood.dev/butterfly/2.2.4 \ No newline at end of file