Skip to content

Commit 764338f

Browse files
Lalit3716gnprice
authored andcommitted
narrow: Rename AllMessagesNarrow to CombinedFeedNarrow
1 parent 6284ed5 commit 764338f

13 files changed

+55
-56
lines changed

integration_test/unreadmarker_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void main() {
4040
child: PerAccountStoreWidget(
4141
accountId: eg.selfAccount.id,
4242
placeholder: const LoadingPlaceholderPage(),
43-
child: const MessageListPage(narrow: AllMessagesNarrow())))));
43+
child: const MessageListPage(narrow: CombinedFeedNarrow())))));
4444
await tester.pumpAndSettle();
4545
return messages;
4646
}

lib/model/message_list.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
332332
/// See also [_allMessagesVisible].
333333
bool _messageVisible(Message message) {
334334
switch (narrow) {
335-
case AllMessagesNarrow():
335+
case CombinedFeedNarrow():
336336
return switch (message) {
337337
StreamMessage() =>
338338
store.isTopicVisible(message.streamId, message.subject),
@@ -355,7 +355,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
355355
/// This is useful for an optimization.
356356
bool get _allMessagesVisible {
357357
switch (narrow) {
358-
case AllMessagesNarrow():
358+
case CombinedFeedNarrow():
359359
case StreamNarrow():
360360
return false;
361361

lib/model/narrow.dart

+7-8
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ sealed class SendableNarrow extends Narrow {
3939
MessageDestination get destination;
4040
}
4141

42-
/// The narrow called "All messages" in the UI.
42+
/// The narrow called "Combined feed" in the UI.
4343
///
44-
/// This does not literally mean all messages, or even all messages
45-
/// that the user has access to: in particular it excludes muted streams
46-
/// and topics.
47-
class AllMessagesNarrow extends Narrow {
48-
const AllMessagesNarrow();
44+
/// All messages the user has access to, excluding unsubscribed streams
45+
/// and muted streams and topics. See [PerAccountStore.isTopicVisible].
46+
class CombinedFeedNarrow extends Narrow {
47+
const CombinedFeedNarrow();
4948

5049
@override
5150
bool containsMessage(Message message) {
@@ -57,13 +56,13 @@ class AllMessagesNarrow extends Narrow {
5756

5857
@override
5958
bool operator ==(Object other) {
60-
if (other is! AllMessagesNarrow) return false;
59+
if (other is! CombinedFeedNarrow) return false;
6160
// Conceptually there's only one value of this type.
6261
return true;
6362
}
6463

6564
@override
66-
int get hashCode => 'AllMessagesNarrow'.hashCode;
65+
int get hashCode => 'CombinedFeedNarrow'.hashCode;
6766
}
6867

6968
class StreamNarrow extends Narrow {

lib/model/unreads.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class Unreads extends ChangeNotifier {
195195

196196
int countInNarrow(Narrow narrow) {
197197
switch (narrow) {
198-
case AllMessagesNarrow():
198+
case CombinedFeedNarrow():
199199
return countInAllMessagesNarrow();
200200
case StreamNarrow():
201201
return countInStreamNarrow(narrow.streamId);

lib/widgets/app.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class HomePage extends StatelessWidget {
271271
ElevatedButton(
272272
onPressed: () => Navigator.push(context,
273273
MessageListPage.buildRoute(context: context,
274-
narrow: const AllMessagesNarrow())),
274+
narrow: const CombinedFeedNarrow())),
275275
child: Text(zulipLocalizations.combinedFeedPageTitle)),
276276
const SizedBox(height: 16),
277277
ElevatedButton(

lib/widgets/compose_box.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ class ComposeBox extends StatelessWidget {
966966
return _FixedDestinationComposeBox(key: controllerKey, narrow: narrow);
967967
} else if (narrow is DmNarrow) {
968968
return _FixedDestinationComposeBox(key: controllerKey, narrow: narrow);
969-
} else if (narrow is AllMessagesNarrow) {
969+
} else if (narrow is CombinedFeedNarrow) {
970970
return const SizedBox.shrink();
971971
} else {
972972
throw Exception("impossible narrow"); // TODO(dart-3): show this statically

lib/widgets/message_list.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class _MessageListPageState extends State<MessageListPage> {
6161
final Color? appBarBackgroundColor;
6262
bool removeAppBarBottomBorder = false;
6363
switch(widget.narrow) {
64-
case AllMessagesNarrow():
64+
case CombinedFeedNarrow():
6565
appBarBackgroundColor = null; // i.e., inherit
6666

6767
case StreamNarrow(:final streamId):
@@ -106,7 +106,7 @@ class _MessageListPageState extends State<MessageListPage> {
106106
// if those details get complicated, refactor to avoid copying.
107107
// TODO(#311) If we have a bottom nav, it will pad the bottom
108108
// inset, and this should always be true.
109-
removeBottom: widget.narrow is! AllMessagesNarrow,
109+
removeBottom: widget.narrow is! CombinedFeedNarrow,
110110

111111
child: Expanded(
112112
child: MessageList(narrow: widget.narrow))),
@@ -142,7 +142,7 @@ class MessageListAppBarTitle extends StatelessWidget {
142142
final zulipLocalizations = ZulipLocalizations.of(context);
143143

144144
switch (narrow) {
145-
case AllMessagesNarrow():
145+
case CombinedFeedNarrow():
146146
return Text(zulipLocalizations.combinedFeedPageTitle);
147147

148148
case StreamNarrow(:var streamId):
@@ -327,7 +327,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
327327
// The keys are of type [ValueKey] with a value of [Message.id]
328328
// and here we use a O(log n) binary search method. This could
329329
// be improved but for now it only triggers for materialized
330-
// widgets. As a simple test, flinging through All Messages in
330+
// widgets. As a simple test, flinging through Combined feed in
331331
// CZO on a Pixel 5, this only runs about 10 times per rebuild
332332
// and the timing for each call is <100 microseconds.
333333
//
@@ -447,7 +447,7 @@ class MarkAsReadWidget extends StatelessWidget {
447447
return;
448448
}
449449
if (!context.mounted) return;
450-
if (narrow is AllMessagesNarrow && !useLegacy) {
450+
if (narrow is CombinedFeedNarrow && !useLegacy) {
451451
PerAccountStoreWidget.of(context).unreads.handleAllMessagesReadSuccess();
452452
}
453453
}
@@ -507,7 +507,7 @@ class RecipientHeader extends StatelessWidget {
507507
final message = this.message;
508508
return switch (message) {
509509
StreamMessage() => StreamMessageRecipientHeader(message: message,
510-
showStream: narrow is AllMessagesNarrow),
510+
showStream: narrow is CombinedFeedNarrow),
511511
DmMessage() => DmRecipientHeader(message: message),
512512
};
513513
}
@@ -1081,7 +1081,7 @@ Future<void> _legacyMarkNarrowAsRead(BuildContext context, Narrow narrow) async
10811081
final store = PerAccountStoreWidget.of(context);
10821082
final connection = store.connection;
10831083
switch (narrow) {
1084-
case AllMessagesNarrow():
1084+
case CombinedFeedNarrow():
10851085
await markAllAsRead(connection);
10861086
case StreamNarrow(:final streamId):
10871087
await markStreamAsRead(connection, streamId: streamId);

test/api/route/messages_test.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void main() {
180180
check(jsonEncode(narrow)).equals(expected);
181181
}
182182

183-
checkNarrow(const AllMessagesNarrow().apiEncode(), jsonEncode([]));
183+
checkNarrow(const CombinedFeedNarrow().apiEncode(), jsonEncode([]));
184184
checkNarrow(const StreamNarrow(12).apiEncode(), jsonEncode([
185185
{'operator': 'stream', 'operand': 12},
186186
]));
@@ -246,7 +246,7 @@ void main() {
246246
return FakeApiConnection.with_((connection) async {
247247
connection.prepare(json: fakeResult.toJson());
248248
await checkGetMessages(connection,
249-
narrow: const AllMessagesNarrow().apiEncode(),
249+
narrow: const CombinedFeedNarrow().apiEncode(),
250250
anchor: AnchorCode.newest, numBefore: 10, numAfter: 20,
251251
expected: {
252252
'narrow': jsonEncode([]),
@@ -278,7 +278,7 @@ void main() {
278278
return FakeApiConnection.with_((connection) async {
279279
connection.prepare(json: fakeResult.toJson());
280280
await checkGetMessages(connection,
281-
narrow: const AllMessagesNarrow().apiEncode(),
281+
narrow: const CombinedFeedNarrow().apiEncode(),
282282
anchor: const NumericAnchor(42),
283283
numBefore: 10, numAfter: 20,
284284
expected: {
@@ -582,7 +582,7 @@ void main() {
582582
await checkUpdateMessageFlagsForNarrow(connection,
583583
anchor: AnchorCode.oldest,
584584
numBefore: 0, numAfter: 20,
585-
narrow: const AllMessagesNarrow().apiEncode(),
585+
narrow: const CombinedFeedNarrow().apiEncode(),
586586
op: UpdateMessageFlagsOp.add, flag: MessageFlag.read,
587587
expected: {
588588
'anchor': 'oldest',
@@ -622,7 +622,7 @@ void main() {
622622
await checkUpdateMessageFlagsForNarrow(connection,
623623
anchor: const NumericAnchor(42),
624624
numBefore: 0, numAfter: 20,
625-
narrow: const AllMessagesNarrow().apiEncode(),
625+
narrow: const CombinedFeedNarrow().apiEncode(),
626626
op: UpdateMessageFlagsOp.add, flag: MessageFlag.read,
627627
expected: {
628628
'anchor': '42',

test/model/autocomplete_test.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void main() {
166166
});
167167

168168
test('MentionAutocompleteView misc', () async {
169-
const narrow = AllMessagesNarrow();
169+
const narrow = CombinedFeedNarrow();
170170
final store = eg.store();
171171
await store.addUsers([eg.selfUser, eg.otherUser, eg.thirdUser]);
172172
final view = MentionAutocompleteView.init(store: store, narrow: narrow);
@@ -183,7 +183,7 @@ void main() {
183183

184184
test('MentionAutocompleteView not starve timers', () {
185185
fakeAsync((binding) async {
186-
const narrow = AllMessagesNarrow();
186+
const narrow = CombinedFeedNarrow();
187187
final store = eg.store();
188188
await store.addUsers([eg.selfUser, eg.otherUser, eg.thirdUser]);
189189
final view = MentionAutocompleteView.init(store: store, narrow: narrow);
@@ -218,7 +218,7 @@ void main() {
218218
});
219219

220220
test('MentionAutocompleteView yield between batches of 1000', () async {
221-
const narrow = AllMessagesNarrow();
221+
const narrow = CombinedFeedNarrow();
222222
final store = eg.store();
223223
for (int i = 0; i < 2500; i++) {
224224
await store.addUser(eg.user(userId: i, email: 'user$i@example.com', fullName: 'User $i'));
@@ -241,7 +241,7 @@ void main() {
241241
});
242242

243243
test('MentionAutocompleteView new query during computation replaces old', () async {
244-
const narrow = AllMessagesNarrow();
244+
const narrow = CombinedFeedNarrow();
245245
final store = eg.store();
246246
for (int i = 0; i < 1500; i++) {
247247
await store.addUser(eg.user(userId: i, email: 'user$i@example.com', fullName: 'User $i'));
@@ -275,7 +275,7 @@ void main() {
275275
});
276276

277277
test('MentionAutocompleteView mutating store.users while in progress causes retry', () async {
278-
const narrow = AllMessagesNarrow();
278+
const narrow = CombinedFeedNarrow();
279279
final store = eg.store();
280280
for (int i = 0; i < 1500; i++) {
281281
await store.addUser(eg.user(userId: i, email: 'user$i@example.com', fullName: 'User $i'));

test/model/compose_test.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ hello
223223
});
224224

225225
group('narrowLink', () {
226-
test('AllMessagesNarrow', () {
226+
test('CombinedFeedNarrow', () {
227227
final store = eg.store();
228-
check(narrowLink(store, const AllMessagesNarrow()))
228+
check(narrowLink(store, const CombinedFeedNarrow()))
229229
.equals(store.realmUrl.resolve('#narrow'));
230-
check(narrowLink(store, const AllMessagesNarrow(), nearMessageId: 1))
230+
check(narrowLink(store, const CombinedFeedNarrow(), nearMessageId: 1))
231231
.equals(store.realmUrl.resolve('#narrow/near/1'));
232232
});
233233

test/model/message_list_test.dart

+9-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void main() async {
3636
void checkNotifiedOnce() => checkNotified(count: 1);
3737

3838
/// Initialize [model] and the rest of the test state.
39-
Future<void> prepare({Narrow narrow = const AllMessagesNarrow()}) async {
39+
Future<void> prepare({Narrow narrow = const CombinedFeedNarrow()}) async {
4040
final stream = eg.stream();
4141
subscription = eg.subscription(stream);
4242
store = eg.store();
@@ -87,7 +87,7 @@ void main() async {
8787
}
8888

8989
test('fetchInitial', () async {
90-
const narrow = AllMessagesNarrow();
90+
const narrow = CombinedFeedNarrow();
9191
await prepare(narrow: narrow);
9292
connection.prepare(json: newestResult(
9393
foundOldest: false,
@@ -140,7 +140,7 @@ void main() async {
140140
});
141141

142142
test('fetchOlder', () async {
143-
const narrow = AllMessagesNarrow();
143+
const narrow = CombinedFeedNarrow();
144144
await prepare(narrow: narrow);
145145
await prepareMessages(foundOldest: false,
146146
messages: List.generate(100, (i) => eg.streamMessage(id: 1000 + i)));
@@ -168,7 +168,7 @@ void main() async {
168168
});
169169

170170
test('fetchOlder nop when already fetching', () async {
171-
const narrow = AllMessagesNarrow();
171+
const narrow = CombinedFeedNarrow();
172172
await prepare(narrow: narrow);
173173
await prepareMessages(foundOldest: false,
174174
messages: List.generate(100, (i) => eg.streamMessage(id: 1000 + i)));
@@ -198,7 +198,7 @@ void main() async {
198198
});
199199

200200
test('fetchOlder nop when already haveOldest true', () async {
201-
await prepare(narrow: const AllMessagesNarrow());
201+
await prepare(narrow: const CombinedFeedNarrow());
202202
await prepareMessages(foundOldest: true, messages:
203203
List.generate(30, (i) => eg.streamMessage()));
204204
check(model)
@@ -216,7 +216,7 @@ void main() async {
216216
});
217217

218218
test('fetchOlder handles servers not understanding includeAnchor', () async {
219-
const narrow = AllMessagesNarrow();
219+
const narrow = CombinedFeedNarrow();
220220
await prepare(narrow: narrow);
221221
await prepareMessages(foundOldest: false,
222222
messages: List.generate(100, (i) => eg.streamMessage(id: 1000 + i)));
@@ -555,10 +555,10 @@ void main() async {
555555
});
556556

557557
group('stream/topic muting', () {
558-
test('in AllMessagesNarrow', () async {
558+
test('in CombinedFeedNarrow', () async {
559559
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
560560
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
561-
await prepare(narrow: const AllMessagesNarrow());
561+
await prepare(narrow: const CombinedFeedNarrow());
562562
await store.addStreams([stream1, stream2]);
563563
await store.addSubscription(eg.subscription(stream1));
564564
await store.addUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
@@ -923,7 +923,7 @@ void checkInvariants(MessageListView model) {
923923

924924
if (message is! StreamMessage) continue;
925925
switch (model.narrow) {
926-
case AllMessagesNarrow():
926+
case CombinedFeedNarrow():
927927
check(model.store.isTopicVisible(message.streamId, message.subject))
928928
.isTrue();
929929
case StreamNarrow():

test/widgets/action_sheet_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ void main() {
442442
));
443443
});
444444

445-
testWidgets('not offered in AllMessagesNarrow (composing to reply is not yet supported)', (WidgetTester tester) async {
445+
testWidgets('not offered in CombinedFeedNarrow (composing to reply is not yet supported)', (WidgetTester tester) async {
446446
final message = eg.streamMessage();
447-
await setupToMessageActionSheet(tester, message: message, narrow: const AllMessagesNarrow());
447+
await setupToMessageActionSheet(tester, message: message, narrow: const CombinedFeedNarrow());
448448
check(findQuoteAndReplyButton(tester)).isNull();
449449
});
450450
});

0 commit comments

Comments
 (0)