Skip to content

Commit

Permalink
api [nfc]: Rename RealmEmojiItem.id to emojiCode
Browse files Browse the repository at this point in the history
This way the binding encapsulates an important fact about this
bit of the API -- namely that these values are the same as the
"emoji code" values seen elsewhere in the API -- so that we don't
have to re-verify it when working elsewhere in the codebase and
using this class.

Also edit a doc comment in the model code to take advantage of
that understanding.
  • Loading branch information
gnprice authored and shivanshsharma13 committed Dec 13, 2024
1 parent 499f2d1 commit 3449419
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/api/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ class CustomProfileFieldExternalAccountData {
/// in <https://zulip.com/api/register-queue>.
@JsonSerializable(fieldRename: FieldRename.snake)
class RealmEmojiItem {
final String id;
@JsonKey(name: 'id')
final String emojiCode;
final String name;
final String sourceUrl;
final String? stillUrl;
final bool deactivated;
final int? authorId;

RealmEmojiItem({
required this.id,
required this.emojiCode,
required this.name,
required this.sourceUrl,
required this.stillUrl,
Expand All @@ -137,7 +138,6 @@ class RealmEmojiItem {
Map<String, dynamic> toJson() => _$RealmEmojiItemToJson(this);
}


/// The name of a user setting that has a property in [UserSettings].
///
/// In Zulip event-handling code (for [UserSettingsUpdateEvent]),
Expand Down
4 changes: 2 additions & 2 deletions lib/api/model/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/model/emoji.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class EmojiStoreImpl with EmojiStore {
/// The same as [PerAccountStore.realmUrl].
final Uri realmUrl;

/// The realm's custom emoji, indexed by [Reaction.emojiCode],
/// The realm's custom emoji, indexed by their [RealmEmojiItem.emojiCode],
/// including deactivated emoji not available for new uses.
///
/// These are the emoji that can have [ReactionType.realmEmoji].
Expand Down
2 changes: 1 addition & 1 deletion test/example_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ RealmEmojiItem realmEmojiItem({
}) {
assert(RegExp(r'^[1-9][0-9]*$').hasMatch(emojiCode));
return RealmEmojiItem(
id: emojiCode,
emojiCode: emojiCode,
name: emojiName,
sourceUrl: sourceUrl ?? '/emoji/$emojiCode.png',
stillUrl: stillUrl,
Expand Down

0 comments on commit 3449419

Please sign in to comment.