fix: open latest after deleting current view

This commit is contained in:
appflowy
2022-09-26 16:59:58 +08:00
parent 81ecbd8ae2
commit e3a1384f7f
11 changed files with 82 additions and 37 deletions

View File

@ -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);