Skip to content

Commit

Permalink
emoji [nfc]: Clarify that deactivated realm emoji are present
Browse files Browse the repository at this point in the history
  • Loading branch information
gnprice authored and shivanshsharma13 committed Dec 13, 2024
1 parent 11c7328 commit 499f2d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions lib/model/emoji.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,18 @@ mixin EmojiStore {
class EmojiStoreImpl with EmojiStore {
EmojiStoreImpl({
required this.realmUrl,
required this.realmEmoji,
required this.allRealmEmoji,
}) : _serverEmojiData = null; // TODO(#974) maybe start from a hard-coded baseline

/// The same as [PerAccountStore.realmUrl].
final Uri realmUrl;

/// The realm's custom emoji (for [ReactionType.realmEmoji],
/// indexed by [Reaction.emojiCode].
Map<String, RealmEmojiItem> realmEmoji;
/// The realm's custom emoji, indexed by [Reaction.emojiCode],
/// including deactivated emoji not available for new uses.
///
/// These are the emoji that can have [ReactionType.realmEmoji].
// TODO(#1113) limit to active realm emoji where appropriate
Map<String, RealmEmojiItem> allRealmEmoji;

/// The realm-relative URL of the unique "Zulip extra emoji", :zulip:.
static const kZulipEmojiUrl = '/static/generated/emoji/images/emoji/unicode/zulip.png';
Expand All @@ -151,7 +154,7 @@ class EmojiStoreImpl with EmojiStore {
return UnicodeEmojiDisplay(emojiName: emojiName, emojiUnicode: parsed);

case ReactionType.realmEmoji:
final item = realmEmoji[emojiCode];
final item = allRealmEmoji[emojiCode];
if (item == null) break;
// TODO we don't check emojiName matches the known realm emoji; is that right?
return _tryImageEmojiDisplay(
Expand Down Expand Up @@ -215,7 +218,7 @@ class EmojiStoreImpl with EmojiStore {
final results = <EmojiCandidate>[];

final namesOverridden = {
for (final emoji in realmEmoji.values) emoji.name,
for (final emoji in allRealmEmoji.values) emoji.name,
'zulip',
};
// TODO(log) if _serverEmojiData missing
Expand All @@ -239,7 +242,7 @@ class EmojiStoreImpl with EmojiStore {
aliases: aliases));
}

for (final entry in realmEmoji.entries) {
for (final entry in allRealmEmoji.entries) {
final emojiName = entry.value.name;
if (emojiName == 'zulip') {
// TODO does 'zulip' really override realm emoji?
Expand Down Expand Up @@ -272,7 +275,7 @@ class EmojiStoreImpl with EmojiStore {
}

void handleRealmEmojiUpdateEvent(RealmEmojiUpdateEvent event) {
realmEmoji = event.realmEmoji;
allRealmEmoji = event.realmEmoji;
_allEmojiCandidates = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/model/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
customProfileFields: _sortCustomProfileFields(initialSnapshot.customProfileFields),
emailAddressVisibility: initialSnapshot.emailAddressVisibility,
emoji: EmojiStoreImpl(
realmUrl: realmUrl, realmEmoji: initialSnapshot.realmEmoji),
realmUrl: realmUrl, allRealmEmoji: initialSnapshot.realmEmoji),
accountId: accountId,
selfUserId: account.userId,
userSettings: initialSnapshot.userSettings,
Expand Down

0 comments on commit 499f2d1

Please sign in to comment.