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:
@ -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);
|
||||
|
Reference in New Issue
Block a user