Fix false group name and avatar updates.

This commit is contained in:
Alex Hart 2020-09-25 14:46:38 -03:00 committed by Alan Evans
parent 8dbc721c08
commit dc9370c32b
2 changed files with 9 additions and 2 deletions

View File

@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.util.StringUtil;
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil; import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
class EditProfileViewModel extends ViewModel { class EditProfileViewModel extends ViewModel {
@ -121,9 +122,9 @@ class EditProfileViewModel extends ViewModel {
repository.uploadProfile(profileName, repository.uploadProfile(profileName,
displayName, displayName,
!Objects.equals(oldDisplayName, displayName), !Objects.equals(StringUtil.stripBidiProtection(oldDisplayName), displayName),
newAvatar, newAvatar,
oldAvatar != newAvatar, !Arrays.equals(oldAvatar, newAvatar),
uploadResultConsumer); uploadResultConsumer);
} }

View File

@ -181,6 +181,12 @@ public final class StringUtil {
.toString(); .toString();
} }
public static @Nullable String stripBidiProtection(@Nullable String text) {
if (text == null) return null;
return text.replaceAll("[\\u2068\\u2069\\u202c]", "");
}
/** /**
* Trims a {@link CharSequence} of starting and trailing whitespace. Behavior matches * Trims a {@link CharSequence} of starting and trailing whitespace. Behavior matches
* {@link String#trim()} to preserve expectations around results. * {@link String#trim()} to preserve expectations around results.