mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: postpone fetching member (#5648)
This commit is contained in:
parent
bf087bba5d
commit
b09ff040f1
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:appflowy/shared/feature_flags.dart';
|
import 'package:appflowy/shared/feature_flags.dart';
|
||||||
import 'package:appflowy/user/application/user_listener.dart';
|
import 'package:appflowy/user/application/user_listener.dart';
|
||||||
@ -10,7 +12,6 @@ import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
|
|||||||
import 'package:appflowy_result/appflowy_result.dart';
|
import 'package:appflowy_result/appflowy_result.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:protobuf/protobuf.dart';
|
import 'package:protobuf/protobuf.dart';
|
||||||
@ -55,23 +56,22 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
await _userService.openWorkspace(currentWorkspace.workspaceId);
|
await _userService.openWorkspace(currentWorkspace.workspaceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkspaceMemberPB? currentWorkspaceMember;
|
|
||||||
final workspaceMemberResult =
|
|
||||||
await _userService.getWorkspaceMember();
|
|
||||||
currentWorkspaceMember = workspaceMemberResult.fold(
|
|
||||||
(s) => s,
|
|
||||||
(e) => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
currentWorkspace: currentWorkspace,
|
currentWorkspace: currentWorkspace,
|
||||||
workspaces: workspaces,
|
workspaces: workspaces,
|
||||||
isCollabWorkspaceOn: isCollabWorkspaceOn,
|
isCollabWorkspaceOn: isCollabWorkspaceOn,
|
||||||
currentWorkspaceMember: currentWorkspaceMember,
|
|
||||||
actionResult: null,
|
actionResult: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// We wait with fetching the workspace member as it may take some time,
|
||||||
|
/// to avoid blocking the UI from rendering (the sidebar).
|
||||||
|
final workspaceMemberResult =
|
||||||
|
await _userService.getWorkspaceMember();
|
||||||
|
final workspaceMember = workspaceMemberResult.toNullable();
|
||||||
|
|
||||||
|
emit(state.copyWith(currentWorkspaceMember: workspaceMember));
|
||||||
},
|
},
|
||||||
fetchWorkspaces: () async {
|
fetchWorkspaces: () async {
|
||||||
final result = await _fetchWorkspaces();
|
final result = await _fetchWorkspaces();
|
||||||
@ -208,14 +208,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
(e) => state.currentWorkspace,
|
(e) => state.currentWorkspace,
|
||||||
);
|
);
|
||||||
|
|
||||||
WorkspaceMemberPB? currentWorkspaceMember;
|
|
||||||
final workspaceMemberResult =
|
|
||||||
await _userService.getWorkspaceMember();
|
|
||||||
currentWorkspaceMember = workspaceMemberResult.fold(
|
|
||||||
(s) => s,
|
|
||||||
(e) => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
result
|
result
|
||||||
..onSuccess((s) {
|
..onSuccess((s) {
|
||||||
Log.info(
|
Log.info(
|
||||||
@ -229,7 +221,6 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
emit(
|
emit(
|
||||||
state.copyWith(
|
state.copyWith(
|
||||||
currentWorkspace: currentWorkspace,
|
currentWorkspace: currentWorkspace,
|
||||||
currentWorkspaceMember: currentWorkspaceMember,
|
|
||||||
actionResult: UserWorkspaceActionResult(
|
actionResult: UserWorkspaceActionResult(
|
||||||
actionType: UserWorkspaceActionType.open,
|
actionType: UserWorkspaceActionType.open,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -237,6 +228,14 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// We wait with fetching the workspace member as it may take some time,
|
||||||
|
/// to avoid blocking the UI from rendering (the sidebar).
|
||||||
|
final workspaceMemberResult =
|
||||||
|
await _userService.getWorkspaceMember();
|
||||||
|
final workspaceMember = workspaceMemberResult.toNullable();
|
||||||
|
|
||||||
|
emit(state.copyWith(currentWorkspaceMember: workspaceMember));
|
||||||
},
|
},
|
||||||
renameWorkspace: (workspaceId, name) async {
|
renameWorkspace: (workspaceId, name) async {
|
||||||
final result =
|
final result =
|
||||||
|
Loading…
Reference in New Issue
Block a user