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

This reverts commit 8cd0442a1f.
This commit is contained in:
Lucas.Xu 2025-04-21 17:20:44 +08:00
parent 343f7e4fd5
commit 1bcf4e6e8d

View file

@ -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;
final actionType = state.actionResult?.actionType;
// Reset all workspace-specific data
getIt<CachedRecentService>().reset();
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,
),
);
}
// 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());
context
.read<FavoriteBloc>()
.add(const FavoriteEvent.fetchFavorites());
}
},
),
],