Skip to content

Commit db8809b

Browse files
committed
emoji [nfc]: Drop setServerEmojiData from main interface
Instead, leave it as a method on EmojiStoreImpl and on the overall PerAccountStore. Each of these FooStore types, such as EmojiStore, is implemented by both a FooStoreImpl class and the overall PerAccountStore. Nearly all of these types' methods behave exactly the same on both those types; the one implementation just forwards to the other. But this method behaves slightly differently between them: the PerAccountStore implementation will call notifyListeners, while the EmojiStoreImpl implementation doesn't (because it can't, not being the ChangeNotifier itself). That mismatch, when nearly all the other similar methods have an exact match, risks confusion. Mitigate that by removing the method from the EmojiStore interface, so that the two implementations become unrelated methods. (The one other such mismatch is `reconcileMessages`. We'll deal with that one too, in a later commit.)
1 parent 5d0188f commit db8809b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

lib/model/emoji.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ mixin EmojiStore {
122122
// TODO cut debugServerEmojiData once we can query for lists of emoji;
123123
// have tests make those queries end-to-end
124124
Map<String, List<String>>? get debugServerEmojiData;
125-
126-
void setServerEmojiData(ServerEmojiData data);
127125
}
128126

129127
/// The implementation of [EmojiStore] that does the work.
@@ -374,7 +372,6 @@ class EmojiStoreImpl extends PerAccountStoreBase with EmojiStore {
374372
return _allEmojiCandidates ??= _generateAllCandidates();
375373
}
376374

377-
@override
378375
void setServerEmojiData(ServerEmojiData data) {
379376
_serverEmojiData = data.codeToNames;
380377
_popularCandidates = null;

lib/model/store.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,18 +587,17 @@ class PerAccountStore extends PerAccountStoreBase with
587587
@override
588588
Map<String, List<String>>? get debugServerEmojiData => _emoji.debugServerEmojiData;
589589

590-
@override
591-
void setServerEmojiData(ServerEmojiData data) {
592-
_emoji.setServerEmojiData(data);
593-
notifyListeners();
594-
}
595-
596590
@override
597591
Iterable<EmojiCandidate> popularEmojiCandidates() => _emoji.popularEmojiCandidates();
598592

599593
@override
600594
Iterable<EmojiCandidate> allEmojiCandidates() => _emoji.allEmojiCandidates();
601595

596+
void setServerEmojiData(ServerEmojiData data) {
597+
_emoji.setServerEmojiData(data);
598+
notifyListeners();
599+
}
600+
602601
EmojiStoreImpl _emoji;
603602

604603
//|//////////////////////////////

0 commit comments

Comments
 (0)