Skip to content

Commit e6f4576

Browse files
committed
api: Require InitialSnapshot.userSettings, present since Zulip Server 5
Related: #268
1 parent bf3fe42 commit e6f4576

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ class InitialSnapshot {
6868

6969
final List<ZulipStream> streams;
7070

71-
// Servers pre-5.0 don't have `user_settings`, and instead provide whatever
72-
// user settings they support at toplevel in the initial snapshot. Since we're
73-
// likely to desupport pre-5.0 servers before wide release, we prefer to
74-
// ignore the toplevel fields and use `user_settings` where present instead,
75-
// even at the expense of functionality with pre-5.0 servers.
76-
// TODO(server-5) remove pre-5.0 comment
77-
final UserSettings? userSettings; // TODO(server-5)
71+
final UserSettings userSettings;
7872

7973
final List<UserTopicItem>? userTopics; // TODO(server-6)
8074

lib/api/model/initial_snapshot.g.dart

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model/store.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ class PerAccountStore extends PerAccountStoreBase with
663663
////////////////////////////////
664664
// Data attached to the self-account on the realm.
665665

666-
final UserSettings? userSettings; // TODO(server-5)
666+
final UserSettings userSettings;
667667

668668
@override
669669
Map<int, SavedSnippet> get savedSnippets => _savedSnippets.savedSnippets;
@@ -907,11 +907,11 @@ class PerAccountStore extends PerAccountStoreBase with
907907
}
908908
switch (event.property!) {
909909
case UserSettingName.twentyFourHourTime:
910-
userSettings?.twentyFourHourTime = event.value as bool;
910+
userSettings.twentyFourHourTime = event.value as bool;
911911
case UserSettingName.displayEmojiReactionUsers:
912-
userSettings?.displayEmojiReactionUsers = event.value as bool;
912+
userSettings.displayEmojiReactionUsers = event.value as bool;
913913
case UserSettingName.emojiset:
914-
userSettings?.emojiset = event.value as Emojiset;
914+
userSettings.emojiset = event.value as Emojiset;
915915
}
916916
notifyListeners();
917917

lib/widgets/emoji_reaction.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class ReactionChipsList extends StatelessWidget {
121121
@override
122122
Widget build(BuildContext context) {
123123
final store = PerAccountStoreWidget.of(context);
124-
final displayEmojiReactionUsers = store.userSettings?.displayEmojiReactionUsers ?? false;
124+
final displayEmojiReactionUsers = store.userSettings.displayEmojiReactionUsers ?? false;
125125
final showNames = displayEmojiReactionUsers && reactions.total <= 3;
126126

127127
return Wrap(spacing: 4, runSpacing: 4, crossAxisAlignment: WrapCrossAlignment.center,

test/model/store_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,14 @@ void main() {
821821
await preparePoll();
822822

823823
// Pick some arbitrary event and check it gets processed on the store.
824-
check(store.userSettings!.twentyFourHourTime).isFalse();
824+
check(store.userSettings.twentyFourHourTime).isFalse();
825825
connection.prepare(json: GetEventsResult(events: [
826826
UserSettingsUpdateEvent(id: 2,
827827
property: UserSettingName.twentyFourHourTime, value: true),
828828
], queueId: null).toJson());
829829
updateMachine.debugAdvanceLoop();
830830
async.elapse(Duration.zero);
831-
check(store.userSettings!.twentyFourHourTime).isTrue();
831+
check(store.userSettings.twentyFourHourTime).isTrue();
832832
}));
833833

834834
void checkReload(FutureOr<void> Function() prepareError, {
@@ -858,14 +858,14 @@ void main() {
858858
// The new UpdateMachine updates the new store.
859859
updateMachine.debugPauseLoop();
860860
updateMachine.poll();
861-
check(store.userSettings!.twentyFourHourTime).isFalse();
861+
check(store.userSettings.twentyFourHourTime).isFalse();
862862
connection.prepare(json: GetEventsResult(events: [
863863
UserSettingsUpdateEvent(id: 2,
864864
property: UserSettingName.twentyFourHourTime, value: true),
865865
], queueId: null).toJson());
866866
updateMachine.debugAdvanceLoop();
867867
async.elapse(Duration.zero);
868-
check(store.userSettings!.twentyFourHourTime).isTrue();
868+
check(store.userSettings.twentyFourHourTime).isTrue();
869869
});
870870
}
871871

0 commit comments

Comments
 (0)