Skip to content

Commit c961f6e

Browse files
committed
store: Add realmEmptyTopicDisplayName
Signed-off-by: Zixuan James Li <[email protected]>
1 parent d41bf4b commit c961f6e

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class InitialSnapshot {
8585

8686
final Uri? serverEmojiDataUrl; // TODO(server-6)
8787

88+
final String? realmEmptyTopicDisplayName; // TODO(server-10)
89+
8890
@JsonKey(readValue: _readUsersIsActiveFallbackTrue)
8991
final List<User> realmUsers;
9092
@JsonKey(readValue: _readUsersIsActiveFallbackFalse)
@@ -138,6 +140,7 @@ class InitialSnapshot {
138140
required this.realmDefaultExternalAccounts,
139141
required this.maxFileUploadSizeMib,
140142
required this.serverEmojiDataUrl,
143+
required this.realmEmptyTopicDisplayName,
141144
required this.realmUsers,
142145
required this.realmNonActiveUsers,
143146
required this.crossRealmBots,

lib/api/model/initial_snapshot.g.dart

Lines changed: 3 additions & 0 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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
272272
realmMandatoryTopics: initialSnapshot.realmMandatoryTopics,
273273
realmWaitingPeriodThreshold: initialSnapshot.realmWaitingPeriodThreshold,
274274
maxFileUploadSizeMib: initialSnapshot.maxFileUploadSizeMib,
275+
realmEmptyTopicDisplayName: initialSnapshot.realmEmptyTopicDisplayName,
275276
realmDefaultExternalAccounts: initialSnapshot.realmDefaultExternalAccounts,
276277
customProfileFields: _sortCustomProfileFields(initialSnapshot.customProfileFields),
277278
emailAddressVisibility: initialSnapshot.emailAddressVisibility,
@@ -317,6 +318,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
317318
required this.realmMandatoryTopics,
318319
required this.realmWaitingPeriodThreshold,
319320
required this.maxFileUploadSizeMib,
321+
required String? realmEmptyTopicDisplayName,
320322
required this.realmDefaultExternalAccounts,
321323
required this.customProfileFields,
322324
required this.emailAddressVisibility,
@@ -337,6 +339,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
337339
assert(realmUrl == connection.realmUrl),
338340
assert(emoji.realmUrl == realmUrl),
339341
_globalStore = globalStore,
342+
_realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
340343
_emoji = emoji,
341344
_channels = channels,
342345
_messages = messages;
@@ -384,6 +387,11 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, ChannelStore, Mess
384387
/// For docs, please see [InitialSnapshot.realmWaitingPeriodThreshold].
385388
final int realmWaitingPeriodThreshold; // TODO(#668): update this realm setting
386389
final int maxFileUploadSizeMib; // No event for this.
390+
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting
391+
String get realmEmptyTopicDisplayName {
392+
assert(_realmEmptyTopicDisplayName != null); // TODO(log)
393+
return _realmEmptyTopicDisplayName ?? 'general chat';
394+
}
387395
final Map<String, RealmDefaultExternalAccount> realmDefaultExternalAccounts;
388396
List<CustomProfileField> customProfileFields;
389397
/// For docs, please see [InitialSnapshot.emailAddressVisibility].

test/example_data.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@ TestGlobalStore globalStore({List<Account> accounts = const []}) {
837837
return TestGlobalStore(accounts: accounts);
838838
}
839839

840+
const String defaultRealmEmptyTopicDisplayName = 'test general chat';
841+
840842
InitialSnapshot initialSnapshot({
841843
String? queueId,
842844
int? lastEventId,
@@ -862,6 +864,7 @@ InitialSnapshot initialSnapshot({
862864
Map<String, RealmDefaultExternalAccount>? realmDefaultExternalAccounts,
863865
int? maxFileUploadSizeMib,
864866
Uri? serverEmojiDataUrl,
867+
String? realmEmptyTopicDisplayName,
865868
List<User>? realmUsers,
866869
List<User>? realmNonActiveUsers,
867870
List<User>? crossRealmBots,
@@ -899,6 +902,7 @@ InitialSnapshot initialSnapshot({
899902
maxFileUploadSizeMib: maxFileUploadSizeMib ?? 25,
900903
serverEmojiDataUrl: serverEmojiDataUrl
901904
?? realmUrl.replace(path: '/static/emoji.json'),
905+
realmEmptyTopicDisplayName: realmEmptyTopicDisplayName ?? defaultRealmEmptyTopicDisplayName,
902906
realmUsers: realmUsers ?? [],
903907
realmNonActiveUsers: realmNonActiveUsers ?? [],
904908
crossRealmBots: crossRealmBots ?? [],

0 commit comments

Comments
 (0)