From 722bacd118d328eaac4006528cb31473bd2753ed Mon Sep 17 00:00:00 2001 From: hewyyy Date: Mon, 11 Apr 2022 18:12:39 -0400 Subject: [PATCH] fix: update view after delete to fix consecutive delete bug --- .../lib/workspace/application/view/view_bloc.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/app_flowy/lib/workspace/application/view/view_bloc.dart b/frontend/app_flowy/lib/workspace/application/view/view_bloc.dart index 1528600236..5b5a953922 100644 --- a/frontend/app_flowy/lib/workspace/application/view/view_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/view/view_bloc.dart @@ -34,12 +34,14 @@ class ViewBloc extends Bloc { }, viewDidUpdate: (e) { e.result.fold( - (view) => emit(state.copyWith(view: view, successOrFailure: left(unit))), + (view) => + emit(state.copyWith(view: view, successOrFailure: left(unit))), (error) => emit(state.copyWith(successOrFailure: right(error))), ); }, rename: (e) async { - final result = await service.updateView(viewId: view.id, name: e.newName); + final result = + await service.updateView(viewId: view.id, name: e.newName); emit( result.fold( (l) => state.copyWith(successOrFailure: left(unit)), @@ -49,6 +51,7 @@ class ViewBloc extends Bloc { }, delete: (e) async { final result = await service.delete(viewId: view.id); + await service.updateView(viewId: view.id); emit( result.fold( (l) => state.copyWith(successOrFailure: left(unit)), @@ -83,7 +86,8 @@ class ViewEvent with _$ViewEvent { const factory ViewEvent.rename(String newName) = Rename; const factory ViewEvent.delete() = Delete; const factory ViewEvent.duplicate() = Duplicate; - const factory ViewEvent.viewDidUpdate(Either result) = ViewDidUpdate; + const factory ViewEvent.viewDidUpdate(Either result) = + ViewDidUpdate; } @freezed