Skip to content

Commit 036ef93

Browse files
committed
store: Add realmEmptyTopicDisplayName
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 78f58ac commit 036ef93

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
302302
realmMandatoryTopics: initialSnapshot.realmMandatoryTopics,
303303
realmWaitingPeriodThreshold: initialSnapshot.realmWaitingPeriodThreshold,
304304
maxFileUploadSizeMib: initialSnapshot.maxFileUploadSizeMib,
305+
realmEmptyTopicDisplayName: initialSnapshot.realmEmptyTopicDisplayName,
305306
realmDefaultExternalAccounts: initialSnapshot.realmDefaultExternalAccounts,
306307
customProfileFields: _sortCustomProfileFields(initialSnapshot.customProfileFields),
307308
emailAddressVisibility: initialSnapshot.emailAddressVisibility,
@@ -344,6 +345,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
344345
required this.realmMandatoryTopics,
345346
required this.realmWaitingPeriodThreshold,
346347
required this.maxFileUploadSizeMib,
348+
required String? realmEmptyTopicDisplayName,
347349
required this.realmDefaultExternalAccounts,
348350
required this.customProfileFields,
349351
required this.emailAddressVisibility,
@@ -362,6 +364,7 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
362364
assert(realmUrl == connection.realmUrl),
363365
assert(emoji.realmUrl == realmUrl),
364366
_globalStore = globalStore,
367+
_realmEmptyTopicDisplayName = realmEmptyTopicDisplayName,
365368
_emoji = emoji,
366369
_users = users,
367370
_channels = channels,
@@ -414,6 +417,18 @@ class PerAccountStore extends ChangeNotifier with EmojiStore, UserStore, Channel
414417
/// For docs, please see [InitialSnapshot.realmWaitingPeriodThreshold].
415418
final int realmWaitingPeriodThreshold; // TODO(#668): update this realm setting
416419
final int maxFileUploadSizeMib; // No event for this.
420+
421+
/// The display name to use for empty topics.
422+
///
423+
/// This should only be accessed when FL >= 334, since topics cannot
424+
/// be empty otherwise.
425+
// TODO(server-10) simplify this
426+
String get realmEmptyTopicDisplayName {
427+
assert(_realmEmptyTopicDisplayName != null); // TODO(log)
428+
return _realmEmptyTopicDisplayName ?? 'general chat';
429+
}
430+
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting
431+
417432
final Map<String, RealmDefaultExternalAccount> realmDefaultExternalAccounts;
418433
List<CustomProfileField> customProfileFields;
419434
/// For docs, please see [InitialSnapshot.emailAddressVisibility].

test/example_data.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,8 @@ TestGlobalStore globalStore({List<Account> accounts = const []}) {
881881
}
882882
const _globalStore = globalStore;
883883

884+
const String defaultRealmEmptyTopicDisplayName = 'test general chat';
885+
884886
InitialSnapshot initialSnapshot({
885887
String? queueId,
886888
int? lastEventId,
@@ -906,6 +908,7 @@ InitialSnapshot initialSnapshot({
906908
Map<String, RealmDefaultExternalAccount>? realmDefaultExternalAccounts,
907909
int? maxFileUploadSizeMib,
908910
Uri? serverEmojiDataUrl,
911+
String? realmEmptyTopicDisplayName,
909912
List<User>? realmUsers,
910913
List<User>? realmNonActiveUsers,
911914
List<User>? crossRealmBots,
@@ -943,6 +946,7 @@ InitialSnapshot initialSnapshot({
943946
maxFileUploadSizeMib: maxFileUploadSizeMib ?? 25,
944947
serverEmojiDataUrl: serverEmojiDataUrl
945948
?? realmUrl.replace(path: '/static/emoji.json'),
949+
realmEmptyTopicDisplayName: realmEmptyTopicDisplayName ?? defaultRealmEmptyTopicDisplayName,
946950
realmUsers: realmUsers ?? [],
947951
realmNonActiveUsers: realmNonActiveUsers ?? [],
948952
crossRealmBots: crossRealmBots ?? [],

0 commit comments

Comments
 (0)