mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 06:37:14 -04:00
Revert "fix: left side bar does not reflect right workspace content"
This reverts commit 8cd0442a1f
.
This commit is contained in:
parent
343f7e4fd5
commit
1bcf4e6e8d
1 changed files with 26 additions and 34 deletions
|
@ -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());
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue