fix: remove member request on launch (#5505)

This commit is contained in:
Lucas.Xu 2024-06-11 10:16:32 +08:00 committed by GitHub
parent 6b46372aa0
commit 5012b99c9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,7 +50,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
'init workspace, current workspace: ${currentWorkspace?.workspaceId}, ' 'init workspace, current workspace: ${currentWorkspace?.workspaceId}, '
'workspaces: ${workspaces.map((e) => e.workspaceId)}, isCollabWorkspaceOn: $isCollabWorkspaceOn', 'workspaces: ${workspaces.map((e) => e.workspaceId)}, isCollabWorkspaceOn: $isCollabWorkspaceOn',
); );
final members = await _fetchMembers(currentWorkspace?.workspaceId);
if (currentWorkspace != null && result.$3 == true) { if (currentWorkspace != null && result.$3 == true) {
Log.info('init open workspace: ${currentWorkspace.workspaceId}'); Log.info('init open workspace: ${currentWorkspace.workspaceId}');
await _userService.openWorkspace(currentWorkspace.workspaceId); await _userService.openWorkspace(currentWorkspace.workspaceId);
@ -61,7 +60,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
workspaces: workspaces, workspaces: workspaces,
isCollabWorkspaceOn: isCollabWorkspaceOn, isCollabWorkspaceOn: isCollabWorkspaceOn,
actionResult: null, actionResult: null,
members: members,
), ),
); );
}, },
@ -199,7 +197,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
), ),
(e) => state.currentWorkspace, (e) => state.currentWorkspace,
); );
final members = await _fetchMembers(currentWorkspace?.workspaceId);
result result
..onSuccess((s) { ..onSuccess((s) {
@ -214,7 +211,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
emit( emit(
state.copyWith( state.copyWith(
currentWorkspace: currentWorkspace, currentWorkspace: currentWorkspace,
members: members,
actionResult: UserWorkspaceActionResult( actionResult: UserWorkspaceActionResult(
actionType: UserWorkspaceActionType.open, actionType: UserWorkspaceActionType.open,
isLoading: false, isLoading: false,
@ -418,17 +414,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
..name = workspace.name ..name = workspace.name
..createdAtTimestamp = workspace.createTime; ..createdAtTimestamp = workspace.createTime;
} }
Future<List<WorkspaceMemberPB>> _fetchMembers(
String? workspaceId,
) async {
if (workspaceId == null) {
return [];
}
return _userService
.getWorkspaceMembers(workspaceId)
.fold((s) => s.items, (_) => []);
}
} }
@freezed @freezed
@ -491,7 +476,6 @@ class UserWorkspaceState with _$UserWorkspaceState {
@Default([]) List<UserWorkspacePB> workspaces, @Default([]) List<UserWorkspacePB> workspaces,
@Default(null) UserWorkspaceActionResult? actionResult, @Default(null) UserWorkspaceActionResult? actionResult,
@Default(false) bool isCollabWorkspaceOn, @Default(false) bool isCollabWorkspaceOn,
@Default([]) List<WorkspaceMemberPB> members,
}) = _UserWorkspaceState; }) = _UserWorkspaceState;
factory UserWorkspaceState.initial() => const UserWorkspaceState(); factory UserWorkspaceState.initial() => const UserWorkspaceState();