Skip to content

Commit 2e2944d

Browse files
committed
narrow [nfc]: Move DmNarrow.withUser factory just below plain constructor
As Greg points out: zulip#304 (comment) > It and `ofMessage` and the plain one are the really > general-purpose constructors; as the number of special-purpose > constructors grows, it starts getting pushed down where it's > harder to spot.
1 parent 7adee9a commit 2e2944d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/model/narrow.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,24 @@ class DmNarrow extends Narrow implements SendableNarrow {
146146
assert(allRecipientIds.contains(selfUserId)),
147147
_selfUserId = selfUserId;
148148

149-
factory DmNarrow.ofMessage(DmMessage message, {required int selfUserId}) {
149+
factory DmNarrow.withUser(int userId, {required int selfUserId}) {
150150
return DmNarrow(
151-
allRecipientIds: List.unmodifiable(message.allRecipientIds),
151+
allRecipientIds: {userId, selfUserId}.toList()..sort(),
152152
selfUserId: selfUserId,
153153
);
154154
}
155155

156-
/// A [DmNarrow] from an item in [InitialSnapshot.recentPrivateConversations].
157-
factory DmNarrow.ofRecentDmConversation(RecentDmConversation conversation, {required int selfUserId}) {
156+
factory DmNarrow.ofMessage(DmMessage message, {required int selfUserId}) {
158157
return DmNarrow(
159-
allRecipientIds: [...conversation.userIds, selfUserId]..sort(),
158+
allRecipientIds: List.unmodifiable(message.allRecipientIds),
160159
selfUserId: selfUserId,
161160
);
162161
}
163162

164-
factory DmNarrow.withUser(int userId, {required int selfUserId}) {
163+
/// A [DmNarrow] from an item in [InitialSnapshot.recentPrivateConversations].
164+
factory DmNarrow.ofRecentDmConversation(RecentDmConversation conversation, {required int selfUserId}) {
165165
return DmNarrow(
166-
allRecipientIds: {userId, selfUserId}.toList()..sort(),
166+
allRecipientIds: [...conversation.userIds, selfUserId]..sort(),
167167
selfUserId: selfUserId,
168168
);
169169
}

0 commit comments

Comments
 (0)