Skip to content

Commit d4afa40

Browse files
committed
message [nfc]: Use getter for realmEmptyTopicDisplayName rather than pass down params
This is a bit simpler in itself, and also closer to what we'll want with the help of a substore.
1 parent aaa1e66 commit d4afa40

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/model/message.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ class MessageStoreImpl extends PerAccountStoreBase with MessageStore, _OutboxMes
110110
messages = {};
111111

112112
// This copy of the realm setting is here to bypass the feature-level check
113-
// on the usual getter for it. See the one access site of this field.
113+
// on the usual getter for it. See discussion:
114+
// https://github.com/zulip/zulip-flutter/pull/1472#discussion_r2099069276
115+
// TODO move [TopicName.processLikeServer] to a substore, eliminating this
116+
@override
114117
final String? _realmEmptyTopicDisplayName; // TODO(#668): update this realm setting
115118

116119
@override
@@ -250,11 +253,7 @@ class MessageStoreImpl extends PerAccountStoreBase with MessageStore, _OutboxMes
250253
content: content,
251254
readBySender: true);
252255
}
253-
return _outboxSendMessage(
254-
destination: destination, content: content,
255-
// TODO move [TopicName.processLikeServer] to a substore, eliminating this
256-
// see https://github.com/zulip/zulip-flutter/pull/1472#discussion_r2099069276
257-
realmEmptyTopicDisplayName: _realmEmptyTopicDisplayName);
256+
return _outboxSendMessage(destination: destination, content: content);
258257
}
259258

260259
@override
@@ -773,6 +772,8 @@ class DmOutboxMessage extends OutboxMessage<DmConversation> {
773772

774773
/// Manages the outbox messages portion of [MessageStore].
775774
mixin _OutboxMessageStore on PerAccountStoreBase {
775+
String? get _realmEmptyTopicDisplayName;
776+
776777
late final UnmodifiableMapView<int, OutboxMessage> outboxMessages =
777778
UnmodifiableMapView(_outboxMessages);
778779
final Map<int, OutboxMessage> _outboxMessages = {};
@@ -848,7 +849,6 @@ mixin _OutboxMessageStore on PerAccountStoreBase {
848849
Future<void> _outboxSendMessage({
849850
required MessageDestination destination,
850851
required String content,
851-
required String? realmEmptyTopicDisplayName,
852852
}) async {
853853
assert(!_disposed);
854854
final localMessageId = _nextLocalMessageId++;
@@ -858,8 +858,7 @@ mixin _OutboxMessageStore on PerAccountStoreBase {
858858
StreamDestination(:final streamId, :final topic) =>
859859
StreamConversation(
860860
streamId,
861-
_processTopicLikeServer(
862-
topic, realmEmptyTopicDisplayName: realmEmptyTopicDisplayName),
861+
_processTopicLikeServer(topic),
863862
displayRecipient: null),
864863
DmDestination(:final userIds) => DmConversation(allRecipientIds: userIds),
865864
};
@@ -918,9 +917,7 @@ mixin _OutboxMessageStore on PerAccountStoreBase {
918917
}
919918
}
920919

921-
TopicName _processTopicLikeServer(TopicName topic, {
922-
required String? realmEmptyTopicDisplayName,
923-
}) {
920+
TopicName _processTopicLikeServer(TopicName topic) {
924921
return topic.processLikeServer(
925922
// Processing this just once on creating the outbox message
926923
// allows an uncommon bug, because either of these values can change.
@@ -936,7 +933,7 @@ mixin _OutboxMessageStore on PerAccountStoreBase {
936933
// so that the setting in effect by the time the request arrives
937934
// is different from the setting the client last heard about.
938935
zulipFeatureLevel: zulipFeatureLevel,
939-
realmEmptyTopicDisplayName: realmEmptyTopicDisplayName);
936+
realmEmptyTopicDisplayName: _realmEmptyTopicDisplayName);
940937
}
941938

942939
void _handleOutboxDebounce(int localMessageId) {

0 commit comments

Comments
 (0)