Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Missing state when deleting avatar in chat details edit #2203

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/pages/chat_details/chat_details_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class ChatDetailsEditController extends State<ChatDetailsEdit>
if (avatarFilePicker != null) {
avatarFilePicker = null;
pickAvatarUIState.value = Right(
GetAvatarInitialUIState(),
DeleteAvatarUIStateSuccess(),
);
if (_isEditDescription || _isEditGroupName) {
return;
Expand All @@ -206,7 +206,7 @@ class ChatDetailsEditController extends State<ChatDetailsEdit>
if (avatarAssetEntity != null) {
avatarAssetEntity = null;
pickAvatarUIState.value = Right(
GetAvatarInitialUIState(),
DeleteAvatarUIStateSuccess(),
);
if (_isEditDescription || _isEditGroupName) {
return;
Expand All @@ -216,7 +216,7 @@ class ChatDetailsEditController extends State<ChatDetailsEdit>
}
if (room?.avatar != null) {
pickAvatarUIState.value = Right(
GetAvatarInitialUIState(),
DeleteAvatarUIStateSuccess(),
);
_isDeleteAvatar = true;
if (_isEditDescription || _isEditGroupName) {
Expand Down
111 changes: 67 additions & 44 deletions lib/pages/chat_details/chat_details_edit_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,58 +249,81 @@ class _AvatarBuilder extends StatelessWidget {
return const SizedBox();
},
(success) {
if (PlatformInfos.isMobile &&
success is GetAvatarOnMobileUIStateSuccess) {
if (success.assetEntity == null) {
return child!;
}
return ClipOval(
child: SizedBox.fromSize(
size: const Size.fromRadius(
ChatDetailEditViewStyle.avatarRadiusForMobile,
),
child: AssetEntityImage(
success.assetEntity!,
thumbnailSize: const ThumbnailSize(
ChatDetailEditViewStyle.thumbnailSizeWidth,
ChatDetailEditViewStyle.thumbnailSizeHeight,
if (PlatformInfos.isMobile) {
if (success is GetAvatarOnMobileUIStateSuccess) {
if (success.assetEntity == null) {
return child!;
}
return ClipOval(
child: SizedBox.fromSize(
size: const Size.fromRadius(
ChatDetailEditViewStyle.avatarRadiusForMobile,
),
fit: BoxFit.cover,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress != null &&
loadingProgress.cumulativeBytesLoaded !=
loadingProgress.expectedTotalBytes) {
child: AssetEntityImage(
success.assetEntity!,
thumbnailSize: const ThumbnailSize(
ChatDetailEditViewStyle.thumbnailSizeWidth,
ChatDetailEditViewStyle.thumbnailSizeHeight,
),
fit: BoxFit.cover,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress != null &&
loadingProgress.cumulativeBytesLoaded !=
loadingProgress.expectedTotalBytes) {
return const Center(
child: CircularProgressIndicator.adaptive(),
);
}
return child;
},
errorBuilder: (context, error, stackTrace) {
return const Center(
child: CircularProgressIndicator.adaptive(),
child: Icon(Icons.error_outline),
);
}
return child;
},
errorBuilder: (context, error, stackTrace) {
return const Center(
child: Icon(Icons.error_outline),
);
},
},
),
),
),
);
}
);
}

if (PlatformInfos.isWeb && success is GetAvatarOnWebUIStateSuccess) {
if (success.matrixFile?.readStream == null) {
return child!;
if (success is DeleteAvatarUIStateSuccess) {
return Avatar(
fontSize: ChatDetailEditViewStyle.avatarFontSize,
name: room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
size: ChatDetailEditViewStyle.avatarSize(context),
);
}
return ClipOval(
child: SizedBox.fromSize(
size: const Size.fromRadius(
ChatDetailEditViewStyle.avatarRadiusForWeb,
}

if (PlatformInfos.isWeb) {
if (success is GetAvatarOnWebUIStateSuccess) {
if (success.matrixFile?.readStream == null) {
return child!;
}
return ClipOval(
child: SizedBox.fromSize(
size: const Size.fromRadius(
ChatDetailEditViewStyle.avatarRadiusForWeb,
),
child: StreamImageViewer(
matrixFile: success.matrixFile!,
onImageLoaded: onImageLoaded,
),
),
child: StreamImageViewer(
matrixFile: success.matrixFile!,
onImageLoaded: onImageLoaded,
);
}

if (success is DeleteAvatarUIStateSuccess) {
return Avatar(
fontSize: ChatDetailEditViewStyle.avatarFontSize,
name: room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
),
);
size: ChatDetailEditViewStyle.avatarSize(context),
);
}
}
return child!;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,9 @@ class SettingsProfileController extends State<SettingsProfile>
avatarUrl: null,
);
_sendAccountDataEvent(profile: newProfile);
isEditedProfileNotifier.toggle();
if (isEditedProfileNotifier.value) {
isEditedProfileNotifier.toggle();
}
_getCurrentProfile(client, isUpdated: true);
TwakeDialog.hideLoadingDialog(context);
pickAvatarUIState.value = Right<Failure, Success>(
Expand Down
Loading