mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
c009347735
# Conflicts: # frontend/appflowy_flutter/lib/plugins/database_view/application/database_view_service.dart # frontend/appflowy_flutter/lib/plugins/document/presentation/plugins/base/link_to_page_widget.dart # frontend/appflowy_flutter/lib/plugins/trash/application/trash_bloc.dart # frontend/appflowy_flutter/lib/plugins/trash/application/trash_service.dart # frontend/appflowy_flutter/lib/workspace/application/app/app_bloc.dart # frontend/appflowy_flutter/lib/workspace/application/app/app_service.dart # frontend/appflowy_flutter/lib/workspace/application/menu/menu_bloc.dart # frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_service.dart # frontend/appflowy_flutter/lib/workspace/presentation/home/menu/app/header/header.dart # frontend/appflowy_flutter/test/bloc_test/grid_test/filter/filter_util.dart # frontend/appflowy_flutter/test/bloc_test/grid_test/grid_bloc_test.dart # frontend/appflowy_flutter/test/bloc_test/grid_test/util.dart # frontend/appflowy_flutter/test/bloc_test/home_test/view_bloc_test.dart # frontend/rust-lib/flowy-database/src/services/database/database_editor.rs # frontend/rust-lib/flowy-database/src/services/persistence/migration/database_view_migration.rs
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:appflowy/startup/plugin/plugin.dart';
|
|
import 'package:appflowy/workspace/application/view/view_listener.dart';
|
|
import 'package:dartz/dartz.dart';
|
|
import 'package:appflowy_backend/log.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ViewPluginNotifier extends PluginNotifier<Option<DeletedViewPB>> {
|
|
final ViewListener? _viewListener;
|
|
ViewPB view;
|
|
|
|
@override
|
|
final ValueNotifier<Option<DeletedViewPB>> isDeleted = ValueNotifier(none());
|
|
|
|
@override
|
|
final ValueNotifier<int> isDisplayChanged = ValueNotifier(0);
|
|
|
|
ViewPluginNotifier({
|
|
required this.view,
|
|
}) : _viewListener = ViewListener(view: view) {
|
|
_viewListener?.start(
|
|
onViewUpdated: (result) {
|
|
result.fold(
|
|
(updatedView) {
|
|
view = updatedView;
|
|
isDisplayChanged.value = updatedView.hashCode;
|
|
},
|
|
(err) => Log.error(err),
|
|
);
|
|
},
|
|
onViewMoveToTrash: (result) {
|
|
result.fold(
|
|
(deletedView) => isDeleted.value = some(deletedView),
|
|
(err) => Log.error(err),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
isDeleted.dispose();
|
|
isDisplayChanged.dispose();
|
|
_viewListener?.stop();
|
|
}
|
|
}
|