mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: open latest after deleting current view
This commit is contained in:
@ -68,9 +68,11 @@ class GridPluginDisplay extends PluginDisplay {
|
||||
@override
|
||||
Widget buildWidget(PluginContext context) {
|
||||
notifier.isDeleted.addListener(() {
|
||||
if (notifier.isDeleted.value) {
|
||||
context.onDeleted(view);
|
||||
}
|
||||
notifier.isDeleted.value.fold(() => null, (deletedView) {
|
||||
if (deletedView.hasIndex()) {
|
||||
context.onDeleted(view, deletedView.index);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return BoardPage(key: ValueKey(view.id), view: view);
|
||||
|
@ -74,15 +74,26 @@ class DocumentPlugin extends Plugin<int> {
|
||||
class DocumentPluginDisplay extends PluginDisplay with NavigationItem {
|
||||
final ViewPluginNotifier notifier;
|
||||
ViewPB get view => notifier.view;
|
||||
int? deletedViewIndex;
|
||||
|
||||
DocumentPluginDisplay({required this.notifier, Key? key});
|
||||
|
||||
@override
|
||||
Widget buildWidget(PluginContext context) => DocumentPage(
|
||||
view: view,
|
||||
onDeleted: () => context.onDeleted(view),
|
||||
key: ValueKey(view.id),
|
||||
);
|
||||
Widget buildWidget(PluginContext context) {
|
||||
notifier.isDeleted.addListener(() {
|
||||
notifier.isDeleted.value.fold(() => null, (deletedView) {
|
||||
if (deletedView.hasIndex()) {
|
||||
deletedViewIndex = deletedView.index;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return DocumentPage(
|
||||
view: view,
|
||||
onDeleted: () => context.onDeleted(view, deletedViewIndex),
|
||||
key: ValueKey(view.id),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget get leftBarItem => ViewLeftBarItem(view: view);
|
||||
|
@ -70,9 +70,11 @@ class GridPluginDisplay extends PluginDisplay {
|
||||
@override
|
||||
Widget buildWidget(PluginContext context) {
|
||||
notifier.isDeleted.addListener(() {
|
||||
if (notifier.isDeleted.value) {
|
||||
context.onDeleted(view);
|
||||
}
|
||||
notifier.isDeleted.value.fold(() => null, (deletedView) {
|
||||
if (deletedView.hasIndex()) {
|
||||
context.onDeleted(view, deletedView.index);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return GridPage(key: ValueKey(view.id), view: view);
|
||||
|
@ -1,15 +1,16 @@
|
||||
import 'package:app_flowy/startup/plugin/plugin.dart';
|
||||
import 'package:app_flowy/workspace/application/view/view_listener.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flowy_sdk/log.dart';
|
||||
import 'package:flowy_sdk/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ViewPluginNotifier extends PluginNotifier {
|
||||
class ViewPluginNotifier extends PluginNotifier<Option<DeletedViewPB>> {
|
||||
final ViewListener? _viewListener;
|
||||
ViewPB view;
|
||||
|
||||
@override
|
||||
final ValueNotifier<bool> isDeleted = ValueNotifier(false);
|
||||
final ValueNotifier<Option<DeletedViewPB>> isDeleted = ValueNotifier(none());
|
||||
|
||||
@override
|
||||
final ValueNotifier<int> isDisplayChanged = ValueNotifier(0);
|
||||
@ -27,9 +28,7 @@ class ViewPluginNotifier extends PluginNotifier {
|
||||
);
|
||||
}, onViewMoveToTrash: (result) {
|
||||
result.fold(
|
||||
(deletedView) {
|
||||
isDeleted.value = true;
|
||||
},
|
||||
(deletedView) => isDeleted.value = some(deletedView),
|
||||
(err) => Log.error(err),
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user