Skip to content

Commit ecb4f7d

Browse files
committed
emoji [nfc]: Make popularEmojiCandidates non-static
1 parent 5973fec commit ecb4f7d

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

lib/model/emoji.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@ mixin EmojiStore {
115115
///
116116
/// See description in the web code:
117117
/// https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L3-L21
118-
// Someday this list may start varying rather than being hard-coded,
119-
// and then this will become a non-static member on EmojiStore.
120-
// For now, though, the fact it's constant is convenient when writing
121-
// tests of the logic that uses this data; so we guarantee it in the API.
122-
static Iterable<EmojiCandidate> get popularEmojiCandidates {
118+
Iterable<EmojiCandidate> get popularEmojiCandidates {
123119
return EmojiStoreImpl._popularCandidates;
124120
}
125121

@@ -320,7 +316,7 @@ class EmojiStoreImpl extends PerAccountStoreBase with EmojiStore {
320316

321317
// Include the "popular" emoji, in their canonical order
322318
// relative to each other.
323-
results.addAll(EmojiStore.popularEmojiCandidates);
319+
results.addAll(popularEmojiCandidates);
324320

325321
final namesOverridden = {
326322
for (final emoji in activeRealmEmoji) emoji.name,

lib/widgets/action_sheet.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,12 @@ class ReactionButtons extends StatelessWidget {
665665

666666
@override
667667
Widget build(BuildContext context) {
668-
assert(EmojiStore.popularEmojiCandidates.every(
668+
final store = PerAccountStoreWidget.of(pageContext);
669+
final popularEmojiCandidates = store.popularEmojiCandidates;
670+
assert(popularEmojiCandidates.every(
669671
(emoji) => emoji.emojiType == ReactionType.unicodeEmoji));
670672

671673
final zulipLocalizations = ZulipLocalizations.of(context);
672-
final store = PerAccountStoreWidget.of(pageContext);
673674
final designVariables = DesignVariables.of(context);
674675

675676
bool hasSelfVote(EmojiCandidate emoji) {
@@ -685,7 +686,7 @@ class ReactionButtons extends StatelessWidget {
685686
color: designVariables.contextMenuItemBg.withFadedAlpha(0.12)),
686687
child: Row(children: [
687688
Flexible(child: Row(spacing: 1, children: List.unmodifiable(
688-
EmojiStore.popularEmojiCandidates.mapIndexed((index, emoji) =>
689+
popularEmojiCandidates.mapIndexed((index, emoji) =>
689690
_buildButton(
690691
context: context,
691692
emoji: emoji,

test/model/emoji_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void main() {
7878
});
7979
});
8080

81-
final popularCandidates = EmojiStore.popularEmojiCandidates;
81+
final popularCandidates = eg.store().popularEmojiCandidates;
8282

8383
Condition<Object?> isUnicodeCandidate(String? emojiCode, List<String>? names) {
8484
return (it_) {

test/widgets/action_sheet_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ void main() {
810810

811811
group('message action sheet', () {
812812
group('ReactionButtons', () {
813-
final popularCandidates = EmojiStore.popularEmojiCandidates;
813+
final popularCandidates = eg.store().popularEmojiCandidates;
814814

815815
for (final emoji in popularCandidates) {
816816
final emojiDisplay = emoji.emojiDisplay as UnicodeEmojiDisplay;

test/widgets/emoji_reaction_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void main() {
299299
// - Non-animated image emoji is selected when intended
300300

301301
group('EmojiPicker', () {
302-
final popularCandidates = EmojiStore.popularEmojiCandidates;
302+
final popularCandidates = eg.store().popularEmojiCandidates;
303303

304304
Future<void> setupEmojiPicker(WidgetTester tester, {
305305
required StreamMessage message,

0 commit comments

Comments
 (0)