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

TW-2112: Fix bug Remove profile picture / avatar doesn't work #2198

Merged
merged 1 commit into from
Dec 20, 2024
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
14 changes: 11 additions & 3 deletions lib/domain/app_state/settings/update_profile_success.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ class UpdateProfileInitial extends Success {
class UpdateProfileSuccess extends Success {
final Uri? avatar;
final String? displayName;
final bool isDeleteAvatar;

const UpdateProfileSuccess({
this.avatar,
this.displayName,
this.isDeleteAvatar = false,
});

@override
List<Object?> get props => [avatar, displayName, isDeleteAvatar];
List<Object?> get props => [avatar, displayName];
}

class DeleteProfileSuccess extends Success {
final String? displayName;

const DeleteProfileSuccess({
this.displayName,
});
@override
List<Object?> get props => [displayName];
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ class UpdateProfileInteractor {
displayName,
);
}
if (isDeleteAvatar) {
yield Right(
DeleteProfileSuccess(
displayName: displayName,
),
);
return;
}
yield Right(
UpdateProfileSuccess(
displayName: displayName,
avatar: avatarUrl,
isDeleteAvatar: isDeleteAvatar,
),
);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,25 @@ class SettingsProfileController extends State<SettingsProfile>
avatarUrl: success.avatar ?? currentProfile.value?.avatarUrl,
);
_sendAccountDataEvent(profile: newProfile);
if (!success.isDeleteAvatar) {
isEditedProfileNotifier.toggle();
}
isEditedProfileNotifier.toggle();
_getCurrentProfile(client, isUpdated: true);
TwakeDialog.hideLoadingDialog(context);
}

if (success is DeleteProfileSuccess) {
final newProfile = Profile(
userId: client.userID!,
displayName: success.displayName ?? displayName,
avatarUrl: null,
);
_sendAccountDataEvent(profile: newProfile);
isEditedProfileNotifier.toggle();
_getCurrentProfile(client, isUpdated: true);
TwakeDialog.hideLoadingDialog(context);
pickAvatarUIState.value = Right<Failure, Success>(
DeleteAvatarUIStateSuccess(),
);
}
},
);
}
Expand Down
7 changes: 7 additions & 0 deletions lib/presentation/model/pick_avatar_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,10 @@ class GetAvatarBigSizeUIStateFailure extends Failure {
@override
List<Object?> get props => [];
}

class DeleteAvatarUIStateSuccess extends PickAvatarState {
DeleteAvatarUIStateSuccess();

@override
List<Object?> get props => [];
}
Loading