Skip to content

Conversation

@MritunjayTiwari14
Copy link
Contributor

Fixes #1981.

@chrisbobbe
Copy link
Collaborator

Let's make a new enum value unknown instead of using google.

@MritunjayTiwari14
Copy link
Contributor Author

Thank you @chrisbobbe for the review, introduced a new enum value unknown to which all the unknow Emojiset are directed to.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Small comments below.

'presence_enabled': true,
});

// Verify unknown emojiset defaults to Emojiset.unknow
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Emojiset.unknown

Comment on lines 69 to 74
final settings = UserSettings.fromJson({
'twenty_four_hour_time': true,
'display_emoji_reaction_users': true,
'emojiset': unknownValue,
'presence_enabled': true,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .fromJson call will fail and need to be debugged each time we add a field to UserSettings.

Can you add a userSettings helper function in test/example_data.dart, on the pattern of similar helpers (like streamMessage or initialSnapshot), then I think this can just be

Suggested change
final settings = UserSettings.fromJson({
'twenty_four_hour_time': true,
'display_emoji_reaction_users': true,
'emojiset': unknownValue,
'presence_enabled': true,
});
final json = eg.userSettings().toJson()..['emojiset'] = unknownValue;
final settings = UserSettings.fromJson(json);

@MritunjayTiwari14
Copy link
Contributor Author

Thank you @chrisbobbe for the Suggestion, have pushed the changes. PTAL.

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just small comments below.

Also something I just noticed on this round: for the commit-message summary line, let's say

api: Accept unknown "emojiset" values in initial snapshot

return UserSettings(
twentyFourHourTime: twentyFourHourTime ?? TwentyFourHourTimeMode.twentyFourHour,
displayEmojiReactionUsers: displayEmojiReactionUsers ?? true,
emojiset: emojiset ?? Emojiset.unknown ,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should aim to make the defaults boring and representative of real data, and I think Emojiset.google would be better for that than Emojiset.unknown.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this helper can deduplicate some code in the initialSnapshot helper just below this.

Just below the userSettings function declaration, you can say

const _userSettings = userSettings;

then in initialSnapshot in choosing arguments for the InitialSnapshot constructor, you can say:

    userSettings: userSettings ?? _userSettings(),

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer review PR ready for review by Zulip maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept unknown "emojiset" values

3 participants