mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
2abb396467
* feat: use result instead of either * chore: remove dartz
32 lines
920 B
Dart
32 lines
920 B
Dart
import 'package:appflowy/startup/plugin/plugin.dart';
|
|
import 'package:appflowy/workspace/application/view/view_listener.dart';
|
|
import 'package:appflowy_backend/log.dart';
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ViewPluginNotifier extends PluginNotifier<DeletedViewPB?> {
|
|
ViewPluginNotifier({
|
|
required this.view,
|
|
}) : _viewListener = ViewListener(viewId: view.id) {
|
|
_viewListener?.start(
|
|
onViewUpdated: (updatedView) => view = updatedView,
|
|
onViewMoveToTrash: (result) => result.fold(
|
|
(deletedView) => isDeleted.value = deletedView,
|
|
(err) => Log.error(err),
|
|
),
|
|
);
|
|
}
|
|
|
|
ViewPB view;
|
|
final ViewListener? _viewListener;
|
|
|
|
@override
|
|
final ValueNotifier<DeletedViewPB?> isDeleted = ValueNotifier(null);
|
|
|
|
@override
|
|
void dispose() {
|
|
isDeleted.dispose();
|
|
_viewListener?.stop();
|
|
}
|
|
}
|