mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: update view after delete to fix consecutive delete bug
This commit is contained in:
parent
a19536d525
commit
722bacd118
@ -34,12 +34,14 @@ class ViewBloc extends Bloc<ViewEvent, ViewState> {
|
|||||||
},
|
},
|
||||||
viewDidUpdate: (e) {
|
viewDidUpdate: (e) {
|
||||||
e.result.fold(
|
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))),
|
(error) => emit(state.copyWith(successOrFailure: right(error))),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
rename: (e) async {
|
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(
|
emit(
|
||||||
result.fold(
|
result.fold(
|
||||||
(l) => state.copyWith(successOrFailure: left(unit)),
|
(l) => state.copyWith(successOrFailure: left(unit)),
|
||||||
@ -49,6 +51,7 @@ class ViewBloc extends Bloc<ViewEvent, ViewState> {
|
|||||||
},
|
},
|
||||||
delete: (e) async {
|
delete: (e) async {
|
||||||
final result = await service.delete(viewId: view.id);
|
final result = await service.delete(viewId: view.id);
|
||||||
|
await service.updateView(viewId: view.id);
|
||||||
emit(
|
emit(
|
||||||
result.fold(
|
result.fold(
|
||||||
(l) => state.copyWith(successOrFailure: left(unit)),
|
(l) => state.copyWith(successOrFailure: left(unit)),
|
||||||
@ -83,7 +86,8 @@ class ViewEvent with _$ViewEvent {
|
|||||||
const factory ViewEvent.rename(String newName) = Rename;
|
const factory ViewEvent.rename(String newName) = Rename;
|
||||||
const factory ViewEvent.delete() = Delete;
|
const factory ViewEvent.delete() = Delete;
|
||||||
const factory ViewEvent.duplicate() = Duplicate;
|
const factory ViewEvent.duplicate() = Duplicate;
|
||||||
const factory ViewEvent.viewDidUpdate(Either<View, FlowyError> result) = ViewDidUpdate;
|
const factory ViewEvent.viewDidUpdate(Either<View, FlowyError> result) =
|
||||||
|
ViewDidUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
|
Loading…
Reference in New Issue
Block a user