mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 12:08:34 +00:00
Fix editing custom reactions.
This commit is contained in:
committed by
Greyson Parrelli
parent
8be946e43f
commit
f65cebdada
@@ -72,6 +72,10 @@ public class EmojiValues extends SignalStoreValues {
|
||||
return getString(PREFIX + canonical, emoji);
|
||||
}
|
||||
|
||||
public void removePreferredVariation(@NonNull String emoji) {
|
||||
getStore().beginWrite().remove(PREFIX + emoji).apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list usable emoji that the user has selected as their defaults. If any stored reactions are unreadable, it will provide a default.
|
||||
* For raw access to the unfiltered list of reactions, see {@link #getRawReactions()}.
|
||||
|
||||
@@ -27,9 +27,7 @@ class EditReactionsViewModel : ViewModel() {
|
||||
fun onEmojiSelected(emoji: String) {
|
||||
store.update { state ->
|
||||
if (state.selection != NO_SELECTION && state.selection in state.reactions.indices) {
|
||||
if (emoji != EmojiUtil.getCanonicalRepresentation(emoji)) {
|
||||
emojiValues.setPreferredVariation(emoji)
|
||||
}
|
||||
emojiValues.setPreferredVariation(emoji)
|
||||
val preferredEmoji: String = emojiValues.getPreferredVariation(emoji)
|
||||
val newReactions: List<String> = state.reactions.toMutableList().apply { set(state.selection, preferredEmoji) }
|
||||
state.copy(reactions = newReactions)
|
||||
@@ -40,6 +38,10 @@ class EditReactionsViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
fun resetToDefaults() {
|
||||
EmojiValues.DEFAULT_REACTIONS_LIST.forEach { emoji ->
|
||||
emojiValues.removePreferredVariation(EmojiUtil.getCanonicalRepresentation(emoji))
|
||||
}
|
||||
|
||||
store.update { it.copy(reactions = EmojiValues.DEFAULT_REACTIONS_LIST) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user