fix: disable collaborators in local mode (#5043)

This commit is contained in:
Lucas.Xu 2024-04-03 10:30:22 +08:00 committed by GitHub
parent dff3ea60bd
commit e022ee88da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -29,12 +29,16 @@ class DocumentCollaboratorsBloc
initial: () async {
final result = await getIt<AuthService>().getUser();
final userProfile = result.fold((s) => s, (f) => null);
if (userProfile == null ||
userProfile.authenticator == AuthenticatorPB.Local) {
emit(
state.copyWith(shouldShowIndicator: false),
);
return;
}
final deviceId = ApplicationInfo.deviceId;
_listener.start(
onDocAwarenessUpdate: (states) {
if (userProfile == null) {
return;
}
add(
DocumentCollaboratorsEvent.update(
userProfile,
@ -114,6 +118,7 @@ class DocumentCollaboratorsEvent with _$DocumentCollaboratorsEvent {
class DocumentCollaboratorsState with _$DocumentCollaboratorsState {
const factory DocumentCollaboratorsState({
@Default([]) List<DocumentAwarenessMetadata> collaborators,
@Default(false) bool shouldShowIndicator,
}) = _DocumentCollaboratorsState;
factory DocumentCollaboratorsState.initial() =>

View File

@ -31,7 +31,7 @@ class DocumentCollaborators extends StatelessWidget {
child: BlocBuilder<DocumentCollaboratorsBloc, DocumentCollaboratorsState>(
builder: (context, state) {
final collaborators = state.collaborators;
if (collaborators.isEmpty) {
if (!state.shouldShowIndicator || collaborators.isEmpty) {
return const SizedBox.shrink();
}