Skip to content

Commit e438374

Browse files
committed
api: Add InitialSnapshot.userSettings, with one user setting to start
This will make [displayEmojiReactionUsers] available for #121, showing message reactions. (Though it won't be live-updated yet; we'll do that soon.) Related: #121
1 parent aa905d7 commit e438374

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ class InitialSnapshot {
3030

3131
final List<ZulipStream> streams;
3232

33+
// Servers pre-5.0 don't have `user_settings`, and instead provide whatever
34+
// user settings they support at toplevel in the initial snapshot. Since we're
35+
// likely to desupport pre-5.0 servers before wide release, we prefer to
36+
// ignore the toplevel fields and use `user_settings` where present instead,
37+
// even at the expense of functionality with pre-5.0 servers.
38+
// TODO(server-5) remove pre-5.0 comment
39+
final UserSettings? userSettings; // TODO(server-5)
40+
3341
final int maxFileUploadSizeMib;
3442

3543
@JsonKey(readValue: _readUsersIsActiveFallbackTrue)
@@ -71,6 +79,7 @@ class InitialSnapshot {
7179
required this.recentPrivateConversations,
7280
required this.subscriptions,
7381
required this.streams,
82+
required this.userSettings,
7483
required this.maxFileUploadSizeMib,
7584
required this.realmUsers,
7685
required this.realmNonActiveUsers,
@@ -102,3 +111,23 @@ class RecentDmConversation {
102111

103112
Map<String, dynamic> toJson() => _$RecentDmConversationToJson(this);
104113
}
114+
115+
/// The `user_settings` dictionary.
116+
///
117+
/// For docs, search for "user_settings:"
118+
/// in <https://zulip.com/api/register-queue>.
119+
@JsonSerializable(fieldRename: FieldRename.snake)
120+
class UserSettings {
121+
final bool? displayEmojiReactionUsers; // TODO(server-6)
122+
123+
// TODO more, as needed
124+
125+
UserSettings({
126+
required this.displayEmojiReactionUsers,
127+
});
128+
129+
factory UserSettings.fromJson(Map<String, dynamic> json) =>
130+
_$UserSettingsFromJson(json);
131+
132+
Map<String, dynamic> toJson() => _$UserSettingsToJson(this);
133+
}

lib/api/model/initial_snapshot.g.dart

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

test/example_data.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ InitialSnapshot initialSnapshot({
208208
List<RecentDmConversation>? recentPrivateConversations,
209209
List<Subscription>? subscriptions,
210210
List<ZulipStream>? streams,
211+
UserSettings? userSettings,
211212
int? maxFileUploadSizeMib,
212213
List<User>? realmUsers,
213214
List<User>? realmNonActiveUsers,
@@ -224,6 +225,7 @@ InitialSnapshot initialSnapshot({
224225
recentPrivateConversations: recentPrivateConversations ?? [],
225226
subscriptions: subscriptions ?? [], // TODO add subscriptions to default
226227
streams: streams ?? [], // TODO add streams to default
228+
userSettings: userSettings, // TODO add userSettings to default
227229
maxFileUploadSizeMib: maxFileUploadSizeMib ?? 25,
228230
realmUsers: realmUsers ?? [],
229231
realmNonActiveUsers: realmNonActiveUsers ?? [],

0 commit comments

Comments
 (0)