mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: optimize recent section performance (#5948)
* fix: duplicated call for setting recent view * chore: reduce recent update
This commit is contained in:
parent
93f9a2cab1
commit
17c9c9b556
@ -1,14 +1,12 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:appflowy/plugins/util.dart';
|
||||
import 'package:appflowy/startup/plugin/plugin.dart';
|
||||
import 'package:appflowy/startup/startup.dart';
|
||||
import 'package:appflowy/workspace/application/recent/cached_recent_service.dart';
|
||||
import 'package:appflowy/workspace/application/view/view_ext.dart';
|
||||
import 'package:appflowy/workspace/presentation/home/home_stack.dart';
|
||||
import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';
|
||||
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'tabs_bloc.freezed.dart';
|
||||
@ -92,8 +90,5 @@ class TabsBloc extends Bloc<TabsEvent, TabsState> {
|
||||
view: view,
|
||||
),
|
||||
);
|
||||
|
||||
// Update recent views
|
||||
getIt<CachedRecentService>().updateRecentViews([view.id], true);
|
||||
}
|
||||
}
|
||||
|
@ -10,19 +10,19 @@ class ViewTitleBarBloc extends Bloc<ViewTitleBarEvent, ViewTitleBarState> {
|
||||
ViewTitleBarBloc({
|
||||
required this.view,
|
||||
}) : super(ViewTitleBarState.initial()) {
|
||||
viewListener = ViewListener(
|
||||
viewId: view.id,
|
||||
)..start(
|
||||
onViewChildViewsUpdated: (p0) {
|
||||
add(const ViewTitleBarEvent.reload());
|
||||
},
|
||||
);
|
||||
|
||||
on<ViewTitleBarEvent>(
|
||||
(event, emit) async {
|
||||
await event.when(
|
||||
initial: () async {
|
||||
add(const ViewTitleBarEvent.reload());
|
||||
|
||||
viewListener = ViewListener(
|
||||
viewId: view.id,
|
||||
)..start(
|
||||
onViewUpdated: (p0) {
|
||||
add(const ViewTitleBarEvent.reload());
|
||||
},
|
||||
);
|
||||
},
|
||||
reload: () async {
|
||||
final List<ViewPB> ancestors =
|
||||
|
@ -143,6 +143,13 @@ class _ViewTitleState extends State<_ViewTitle> {
|
||||
create: (_) =>
|
||||
ViewTitleBloc(view: widget.view)..add(const ViewTitleEvent.initial()),
|
||||
child: BlocConsumer<ViewTitleBloc, ViewTitleState>(
|
||||
listenWhen: (previous, current) {
|
||||
if (previous.view == null || current.view == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return previous.view != current.view;
|
||||
},
|
||||
listener: (_, state) {
|
||||
_resetTextEditingController(state);
|
||||
widget.onUpdated();
|
||||
|
Loading…
Reference in New Issue
Block a user