Skip to content

Commit

Permalink
Hotfix: Missing state when deleting avatar in chat details edit on mo…
Browse files Browse the repository at this point in the history
…bile
  • Loading branch information
nqhhdev authored and hoangdat committed Jan 7, 2025
1 parent 4a349ea commit 12c6731
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 32 deletions.
73 changes: 42 additions & 31 deletions lib/pages/chat_details/chat_details_edit_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,41 +249,52 @@ 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 (success is DeleteAvatarUIStateSuccess) {
return Avatar(
fontSize: ChatDetailEditViewStyle.avatarFontSize,
name: room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
size: ChatDetailEditViewStyle.avatarSize(context),
);
}
}

if (PlatformInfos.isWeb) {
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

0 comments on commit 12c6731

Please sign in to comment.