Skip to content

Commit df1e800

Browse files
initial_snapshot: Accept unknown "emojiset" values
Fixes #1981.
1 parent 550f99c commit df1e800

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ class UserSettings {
295295
TwentyFourHourTimeMode twentyFourHourTime;
296296

297297
bool displayEmojiReactionUsers;
298+
@JsonKey(unknownEnumValue: Emojiset.google)
298299
Emojiset emojiset;
299300
bool presenceEnabled;
300301

lib/api/model/initial_snapshot.g.dart

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/api/model/initial_snapshot_test.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,19 @@ void main() {
6262
'unread_message_ids': [11, 2, 3],
6363
})).throws<AssertionError>();
6464
});
65+
66+
test('UserSettings.emojiset handles various unknown values', () {
67+
final unknownValues = ['apple', 'microsoft', 'facebook', ''];
68+
for (final unknownValue in unknownValues) {
69+
final settings = UserSettings.fromJson({
70+
'twenty_four_hour_time': true,
71+
'display_emoji_reaction_users': true,
72+
'emojiset': unknownValue,
73+
'presence_enabled': true,
74+
});
75+
76+
// Verify unknown emojiset defaults to google
77+
check(settings.emojiset).equals(Emojiset.google);
78+
}
79+
});
6580
}

0 commit comments

Comments
 (0)