feat: enable collab workspace features (#5012)

* feat: enable collab workspace features

* feat: change collaborator background color
This commit is contained in:
Lucas.Xu 2024-04-01 09:07:38 +08:00 committed by GitHub
parent 53dbef25ab
commit 932a403b5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 6 deletions

View File

@ -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,

View File

@ -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,
),
),
),

View File

@ -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]!;
}

View File

@ -31,9 +31,13 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
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<UserWorkspaceEvent, UserWorkspaceState> {
final UserProfilePB userProfile;
final UserBackendService _userService;
Future<(UserWorkspacePB currentWorkspace, List<UserWorkspacePB> workspaces)?>
_fetchWorkspaces() async {
Future<
(
UserWorkspacePB currentWorkspace,
List<UserWorkspacePB> workspaces,
bool shouldOpenWorkspace,
)?> _fetchWorkspaces() async {
try {
final lastOpenedWorkspaceId = await getIt<KeyValueStorage>().get(
KVKeys.lastOpenedWorkspaceId,
@ -268,7 +276,11 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
currentWorkspaceInList = lastOpenedWorkspace;
}
}
return (currentWorkspaceInList, workspaces);
return (
currentWorkspaceInList,
workspaces,
lastOpenedWorkspaceId != currentWorkspace.id
);
} catch (e) {
Log.error('fetch workspace error: $e');
return null;