Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

Revert "fix: left side bar does not reflect right workspace content"

Lucas.Xu1bcf4e6e8d7f
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 d05200cabf..9c19184217 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
@@ -176,43 +176,35 @@ class HomeSideBar extends StatelessWidget {
listener: _onNotificationAction,
),
BlocListener<UserWorkspaceBloc, UserWorkspaceState>(
- listenWhen: (previous, current) =>
- previous.currentWorkspace?.workspaceId !=
- current.currentWorkspace?.workspaceId ||
- current.actionResult?.actionType ==
- UserWorkspaceActionType.create ||
- current.actionResult?.actionType ==
- UserWorkspaceActionType.delete ||
- current.actionResult?.actionType ==
- UserWorkspaceActionType.open,
listener: (context, state) {
- final workspaceId = state.currentWorkspace?.workspaceId ??
- workspaceSetting.workspaceId;
-
- // Reset all workspace-specific data
- getIt<CachedRecentService>().reset();
-
- // Always reload sidebar sections to ensure fresh data
- context.read<SidebarSectionsBloc>().add(
- SidebarSectionsEvent.reload(
- userProfile,
- workspaceId,
- ),
- );
-
- // Reset space data with the current workspace
- context.read<SpaceBloc>().add(
- SpaceEvent.reset(
- userProfile,
- workspaceId,
- true,
- ),
- );
-
- // Fetch updated favorites
- context
- .read<FavoriteBloc>()
- .add(const FavoriteEvent.fetchFavorites());
+ final actionType = state.actionResult?.actionType;
+
+ if (actionType == UserWorkspaceActionType.create ||
+ actionType == UserWorkspaceActionType.delete ||
+ actionType == UserWorkspaceActionType.open) {
+ if (context.read<SpaceBloc>().state.spaces.isEmpty) {
+ context.read<SidebarSectionsBloc>().add(
+ SidebarSectionsEvent.reload(
+ userProfile,
+ state.currentWorkspace?.workspaceId ??
+ workspaceSetting.workspaceId,
+ ),
+ );
+ } else {
+ context.read<SpaceBloc>().add(
+ SpaceEvent.reset(
+ userProfile,
+ state.currentWorkspace?.workspaceId ??
+ workspaceSetting.workspaceId,
+ true,
+ ),
+ );
+ }
+
+ context
+ .read<FavoriteBloc>()
+ .add(const FavoriteEvent.fetchFavorites());
+ }
},
),
],