From 932a403b5dfd838da6cc97623313585f28a8e826 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Mon, 1 Apr 2024 09:07:38 +0800 Subject: [PATCH] feat: enable collab workspace features (#5012) * feat: enable collab workspace features * feat: change collaborator background color --- .../application/doc_collab_adapter.dart | 2 +- .../presentation/document_collaborators.dart | 3 ++- .../lib/shared/feature_flags.dart | 10 ++++++++++ .../application/user/user_workspace_bloc.dart | 20 +++++++++++++++---- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/doc_collab_adapter.dart b/frontend/appflowy_flutter/lib/plugins/document/application/doc_collab_adapter.dart index 656b0c9d85..598dfb3798 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/application/doc_collab_adapter.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/application/doc_collab_adapter.dart @@ -174,7 +174,7 @@ class DocumentCollabAdapter { cursorColor: cursorColor, builder: (_, __, rect) { return Positioned( - top: rect.top - 10, + top: rect.top - 14, left: selection.isCollapsed ? rect.right : rect.left, child: ColoredBox( color: color, diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart index 0d1e074573..c67a038302 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/document_collaborators.dart @@ -48,10 +48,11 @@ class DocumentCollaborators extends StatelessWidget { (c) => FlowyTooltip( message: c.userName, child: CircleAvatar( - backgroundColor: c.selectionColor.tryToColor(), + backgroundColor: c.cursorColor.tryToColor(), child: FlowyText( c.userName.characters.firstOrNull ?? ' ', fontSize: fontSize, + color: Colors.black, ), ), ), diff --git a/frontend/appflowy_flutter/lib/shared/feature_flags.dart b/frontend/appflowy_flutter/lib/shared/feature_flags.dart index b872a1cbed..e2a7b64ece 100644 --- a/frontend/appflowy_flutter/lib/shared/feature_flags.dart +++ b/frontend/appflowy_flutter/lib/shared/feature_flags.dart @@ -81,6 +81,16 @@ enum FeatureFlag { } bool get isOn { + // release this feature in version 0.5.4 + if ([ + FeatureFlag.collaborativeWorkspace, + FeatureFlag.membersSettings, + FeatureFlag.syncDatabase, + FeatureFlag.syncDocument, + ].contains(this)) { + return true; + } + if (_values.containsKey(this)) { return _values[this]!; } diff --git a/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart index 60b86bb9c5..8d0ecbf4b1 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart @@ -31,9 +31,13 @@ class UserWorkspaceBloc extends Bloc { final isCollabWorkspaceOn = userProfile.authenticator != AuthenticatorPB.Local && FeatureFlag.collaborativeWorkspace.isOn; + final currentWorkspace = result?.$1; + if (currentWorkspace != null && result?.$3 == true) { + await _userService.openWorkspace(currentWorkspace.workspaceId); + } emit( state.copyWith( - currentWorkspace: result?.$1, + currentWorkspace: currentWorkspace, workspaces: result?.$2 ?? [], isCollabWorkspaceOn: isCollabWorkspaceOn, actionResult: null, @@ -250,8 +254,12 @@ class UserWorkspaceBloc extends Bloc { final UserProfilePB userProfile; final UserBackendService _userService; - Future<(UserWorkspacePB currentWorkspace, List workspaces)?> - _fetchWorkspaces() async { + Future< + ( + UserWorkspacePB currentWorkspace, + List workspaces, + bool shouldOpenWorkspace, + )?> _fetchWorkspaces() async { try { final lastOpenedWorkspaceId = await getIt().get( KVKeys.lastOpenedWorkspaceId, @@ -268,7 +276,11 @@ class UserWorkspaceBloc extends Bloc { currentWorkspaceInList = lastOpenedWorkspace; } } - return (currentWorkspaceInList, workspaces); + return ( + currentWorkspaceInList, + workspaces, + lastOpenedWorkspaceId != currentWorkspace.id + ); } catch (e) { Log.error('fetch workspace error: $e'); return null;