Skip to content

Commit 4b56bba

Browse files
committed
narrow [nfc]: Inline away TopicNarrow.processTopicLikeServer
This will help us move the underlying logic to live on a substore, which in turn will let us save these advance lookups and the annoying zulipFeatureLevel conditional.
1 parent fea9e01 commit 4b56bba

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

lib/model/narrow.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,6 @@ class TopicNarrow extends Narrow implements SendableNarrow {
108108

109109
TopicNarrow sansWith() => TopicNarrow(streamId, topic);
110110

111-
/// Process [topic] to match how it would appear on a message object from
112-
/// the server.
113-
///
114-
/// Returns a new [TopicNarrow] with the [topic] processed.
115-
///
116-
/// See [TopicName.processLikeServer].
117-
TopicNarrow processTopicLikeServer({
118-
required int zulipFeatureLevel,
119-
required String? realmEmptyTopicDisplayName,
120-
}) {
121-
return TopicNarrow(
122-
streamId,
123-
topic.processLikeServer(
124-
zulipFeatureLevel: zulipFeatureLevel,
125-
realmEmptyTopicDisplayName: realmEmptyTopicDisplayName),
126-
with_: with_);
127-
}
128-
129111
@override
130112
bool containsMessage(MessageBase message) {
131113
final conversation = message.conversation;

lib/widgets/message_list.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,16 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
774774
}
775775

776776
void _initModel(PerAccountStore store, Anchor anchor) {
777-
// Normalize topic name if this is a TopicNarrow. See #1717.
778777
var narrow = widget.narrow;
779778
if (narrow is TopicNarrow) {
780-
narrow = narrow.processTopicLikeServer(
781-
zulipFeatureLevel: store.zulipFeatureLevel,
782-
realmEmptyTopicDisplayName: store.zulipFeatureLevel > 334
783-
? store.realmEmptyTopicDisplayName
784-
: null);
779+
// Normalize topic name. See #1717.
780+
narrow = TopicNarrow(narrow.streamId,
781+
narrow.topic.processLikeServer(
782+
zulipFeatureLevel: store.zulipFeatureLevel,
783+
realmEmptyTopicDisplayName: store.zulipFeatureLevel > 334
784+
? store.realmEmptyTopicDisplayName
785+
: null),
786+
with_: narrow.with_);
785787
if (narrow != widget.narrow) {
786788
SchedulerBinding.instance.scheduleFrameCallback((_) {
787789
widget.onNarrowChanged(narrow);

0 commit comments

Comments
 (0)