mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Fix group name clearing after avatar change.
This commit is contained in:
committed by
Greyson Parrelli
parent
8dbcb255ad
commit
d8f3e032c7
@@ -15,7 +15,14 @@ interface EditProfileRepository {
|
||||
|
||||
void getCurrentDisplayName(@NonNull Consumer<String> displayNameConsumer);
|
||||
|
||||
void uploadProfile(@NonNull ProfileName profileName, @Nullable String displayName, @Nullable byte[] avatar, boolean avatarChanged, @NonNull Consumer<UploadResult> uploadResultConsumer);
|
||||
void getCurrentName(@NonNull Consumer<String> nameConsumer);
|
||||
|
||||
void uploadProfile(@NonNull ProfileName profileName,
|
||||
@NonNull String displayName,
|
||||
boolean displayNameChanged,
|
||||
@Nullable byte[] avatar,
|
||||
boolean avatarChanged,
|
||||
@NonNull Consumer<UploadResult> uploadResultConsumer);
|
||||
|
||||
void getCurrentUsername(@NonNull Consumer<Optional<String>> callback);
|
||||
|
||||
|
||||
@@ -39,10 +39,8 @@ class EditProfileViewModel extends ViewModel {
|
||||
|
||||
if (!hasInstanceState) {
|
||||
if (groupId != null) {
|
||||
repository.getCurrentDisplayName(value -> {
|
||||
givenName.setValue(value);
|
||||
originalDisplayName.setValue(value);
|
||||
});
|
||||
repository.getCurrentDisplayName(originalDisplayName::setValue);
|
||||
repository.getCurrentName(givenName::setValue);
|
||||
} else {
|
||||
repository.getCurrentProfileName(name -> {
|
||||
givenName.setValue(name.getGivenName());
|
||||
@@ -123,7 +121,8 @@ class EditProfileViewModel extends ViewModel {
|
||||
String oldDisplayName = isGroup() ? originalDisplayName.getValue() : null;
|
||||
|
||||
repository.uploadProfile(profileName,
|
||||
Objects.equals(oldDisplayName, displayName) ? null : displayName,
|
||||
displayName,
|
||||
!Objects.equals(oldDisplayName, displayName),
|
||||
newAvatar,
|
||||
oldAvatar != newAvatar,
|
||||
uploadResultConsumer);
|
||||
|
||||
@@ -65,16 +65,22 @@ class EditPushGroupProfileRepository implements EditProfileRepository {
|
||||
SimpleTask.run(() -> Recipient.resolved(getRecipientId()).getDisplayName(context), displayNameConsumer::accept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCurrentName(@NonNull Consumer<String> nameConsumer) {
|
||||
SimpleTask.run(() -> Recipient.resolved(getRecipientId()).getName(context), nameConsumer::accept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProfile(@NonNull ProfileName profileName,
|
||||
@Nullable String displayName,
|
||||
@NonNull String displayName,
|
||||
boolean displayNameChanged,
|
||||
@Nullable byte[] avatar,
|
||||
boolean avatarChanged,
|
||||
@NonNull Consumer<UploadResult> uploadResultConsumer)
|
||||
{
|
||||
SimpleTask.run(() -> {
|
||||
try {
|
||||
GroupManager.updateGroup(context, groupId, avatar, avatarChanged, displayName);
|
||||
GroupManager.updateGroup(context, groupId, avatar, avatarChanged, displayName, displayNameChanged);
|
||||
|
||||
return UploadResult.SUCCESS;
|
||||
} catch (GroupChangeFailedException | GroupInsufficientRightsException | IOException | GroupNotAMemberException | GroupChangeBusyException e) {
|
||||
|
||||
@@ -108,7 +108,18 @@ class EditSelfProfileRepository implements EditProfileRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProfile(@NonNull ProfileName profileName, @Nullable String displayName, @Nullable byte[] avatar, boolean avatarChanged, @NonNull Consumer<UploadResult> uploadResultConsumer) {
|
||||
public void getCurrentName(@NonNull Consumer<String> nameConsumer) {
|
||||
nameConsumer.accept("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProfile(@NonNull ProfileName profileName,
|
||||
@NonNull String displayName,
|
||||
boolean displayNameChanged,
|
||||
@Nullable byte[] avatar,
|
||||
boolean avatarChanged,
|
||||
@NonNull Consumer<UploadResult> uploadResultConsumer)
|
||||
{
|
||||
SimpleTask.run(() -> {
|
||||
DatabaseFactory.getRecipientDatabase(context).setProfileName(Recipient.self().getId(), profileName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user