From 63c76f68433184f96ae3225a9e19a9360a13f9a7 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Sat, 27 Jul 2024 22:01:11 +0800 Subject: [PATCH] fix: only rebuild the sidebar header when needed --- .../home/menu/sidebar/sidebar.dart | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart index 3481981130..f6c75ff9d1 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart @@ -275,7 +275,6 @@ class _SidebarState extends State<_Sidebar> { @override Widget build(BuildContext context) { const menuHorizontalInset = EdgeInsets.symmetric(horizontal: 8); - final userState = context.read().state; return MouseRegion( onEnter: (_) => _isHovered.value = true, onExit: (_) => _isHovered.value = false, @@ -297,15 +296,19 @@ class _SidebarState extends State<_Sidebar> { ), ), // user or workspace, setting - Container( - height: HomeSizes.workspaceSectionHeight, - padding: menuHorizontalInset - const EdgeInsets.only(right: 6), - child: - // if the workspaces are empty, show the user profile instead - userState.isCollabWorkspaceOn && - userState.workspaces.isNotEmpty - ? SidebarWorkspace(userProfile: widget.userProfile) - : SidebarUser(userProfile: widget.userProfile), + BlocBuilder( + builder: (context, state) { + return Container( + height: HomeSizes.workspaceSectionHeight, + padding: + menuHorizontalInset - const EdgeInsets.only(right: 6), + child: + // if the workspaces are empty, show the user profile instead + state.isCollabWorkspaceOn && state.workspaces.isNotEmpty + ? SidebarWorkspace(userProfile: widget.userProfile) + : SidebarUser(userProfile: widget.userProfile), + ); + }, ), if (FeatureFlag.search.isOn) ...[ const VSpace(6),