Skip to content

Commit 4bcbffd

Browse files
chrisbobbegnprice
authored andcommitted
api: Add UserSettings.twentyFourHourTime
Not because we have an immediate need to read this user setting. Rather, this demonstrates how much boilerplate it would take to handle a new setting, with the setup from the previous commit.
1 parent 9cb2e4d commit 4bcbffd

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

lib/api/model/events.dart

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class UserSettingsUpdateEvent extends Event {
107107
static Object? _readValue(Map json, String key) {
108108
final value = json['value'];
109109
switch (UserSettingName.fromRawString(json['property'] as String)) {
110+
case UserSettingName.twentyFourHourTime:
110111
case UserSettingName.displayEmojiReactionUsers:
111112
return value as bool;
112113
case null:

lib/api/model/events.g.dart

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/model/initial_snapshot.dart

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class RecentDmConversation {
119119
/// in <https://zulip.com/api/register-queue>.
120120
@JsonSerializable(fieldRename: FieldRename.snake, createFieldMap: true)
121121
class UserSettings {
122+
bool twentyFourHourTime;
122123
bool? displayEmojiReactionUsers; // TODO(server-6)
123124

124125
// TODO more, as needed. When adding a setting here, please also:
@@ -127,6 +128,7 @@ class UserSettings {
127128
// (3) handle the event that signals an update to the setting
128129

129130
UserSettings({
131+
required this.twentyFourHourTime,
130132
required this.displayEmojiReactionUsers,
131133
});
132134

@@ -148,6 +150,7 @@ class UserSettings {
148150
/// to ensure that every setting in [UserSettings] responds to the event.
149151
@JsonEnum(fieldRename: FieldRename.snake, alwaysCreate: true)
150152
enum UserSettingName {
153+
twentyFourHourTime,
151154
displayEmojiReactionUsers;
152155

153156
/// Get a [UserSettingName] from a raw, snake-case string we recognize, else null.

lib/api/model/initial_snapshot.g.dart

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model/store.dart

+2
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class PerAccountStore extends ChangeNotifier {
226226
return;
227227
}
228228
switch (event.property!) {
229+
case UserSettingName.twentyFourHourTime:
230+
userSettings?.twentyFourHourTime = event.value as bool;
229231
case UserSettingName.displayEmojiReactionUsers:
230232
userSettings?.displayEmojiReactionUsers = event.value as bool;
231233
}

0 commit comments

Comments
 (0)