Skip to content

Commit 8ff3c68

Browse files
committed
narrow: Rename AllMessagesNarrow to CombinedFeedNarrow
Fixes: zulip#676
1 parent 19ed919 commit 8ff3c68

13 files changed

+52
-56
lines changed

integration_test/unreadmarker_test.dart

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,9 @@ sealed class SendableNarrow extends Narrow {
3939
MessageDestination get destination;
4040
}
4141

42-
/// The narrow called "All messages" in the UI.
43-
///
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();
42+
/// The narrow called "Combined feed" in the UI.
43+
class CombinedFeedNarrow extends Narrow {
44+
const CombinedFeedNarrow();
4945

5046
@override
5147
bool containsMessage(Message message) {
@@ -57,13 +53,13 @@ class AllMessagesNarrow extends Narrow {
5753

5854
@override
5955
bool operator ==(Object other) {
60-
if (other is! AllMessagesNarrow) return false;
56+
if (other is! CombinedFeedNarrow) return false;
6157
// Conceptually there's only one value of this type.
6258
return true;
6359
}
6460

6561
@override
66-
int get hashCode => 'AllMessagesNarrow'.hashCode;
62+
int get hashCode => 'CombinedFeedNarrow'.hashCode;
6763
}
6864

6965
class StreamNarrow extends Narrow {

lib/model/unreads.dart

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class _MessageListPageState extends State<MessageListPage> {
6161
final Color? backgroundColor;
6262
bool removeAppBarBottomBorder = false;
6363
switch(widget.narrow) {
64-
case AllMessagesNarrow():
64+
case CombinedFeedNarrow():
6565
backgroundColor = 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):
@@ -449,7 +449,7 @@ class MarkAsReadWidget extends StatelessWidget {
449449
return;
450450
}
451451
if (!context.mounted) return;
452-
if (narrow is AllMessagesNarrow && !useLegacy) {
452+
if (narrow is CombinedFeedNarrow && !useLegacy) {
453453
PerAccountStoreWidget.of(context).unreads.handleAllMessagesReadSuccess();
454454
}
455455
}
@@ -508,7 +508,7 @@ class RecipientHeader extends StatelessWidget {
508508
final message = this.message;
509509
return switch (message) {
510510
StreamMessage() => StreamMessageRecipientHeader(message: message,
511-
showStream: narrow is AllMessagesNarrow),
511+
showStream: narrow is CombinedFeedNarrow),
512512
DmMessage() => DmRecipientHeader(message: message),
513513
};
514514
}
@@ -1089,7 +1089,7 @@ Future<void> _legacyMarkNarrowAsRead(BuildContext context, Narrow narrow) async
10891089
final store = PerAccountStoreWidget.of(context);
10901090
final connection = store.connection;
10911091
switch (narrow) {
1092-
case AllMessagesNarrow():
1092+
case CombinedFeedNarrow():
10931093
await markAllAsRead(connection);
10941094
case StreamNarrow(:final streamId):
10951095
await markStreamAsRead(connection, streamId: streamId);

test/api/route/messages_test.dart

Lines changed: 5 additions & 5 deletions
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

Lines changed: 5 additions & 5 deletions
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
..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) {
186-
const narrow = AllMessagesNarrow();
186+
const narrow = CombinedFeedNarrow();
187187
final store = eg.store()
188188
..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
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
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
store.addUser(eg.user(userId: i, email: 'user$i@example.com', fullName: 'User $i'));

test/model/compose_test.dart

Lines changed: 3 additions & 3 deletions
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

Lines changed: 9 additions & 9 deletions
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-
void prepare({Narrow narrow = const AllMessagesNarrow()}) {
39+
void prepare({Narrow narrow = const CombinedFeedNarrow()}) {
4040
final stream = eg.stream();
4141
subscription = eg.subscription(stream);
4242
store = eg.store()
@@ -86,7 +86,7 @@ void main() async {
8686
}
8787

8888
test('fetchInitial', () async {
89-
const narrow = AllMessagesNarrow();
89+
const narrow = CombinedFeedNarrow();
9090
prepare(narrow: narrow);
9191
connection.prepare(json: newestResult(
9292
foundOldest: false,
@@ -139,7 +139,7 @@ void main() async {
139139
});
140140

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

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

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

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

556556
group('stream/topic muting', () {
557-
test('in AllMessagesNarrow', () async {
557+
test('in CombinedFeedNarrow', () async {
558558
final stream1 = eg.stream(streamId: 1, name: 'stream 1');
559559
final stream2 = eg.stream(streamId: 2, name: 'stream 2');
560-
prepare(narrow: const AllMessagesNarrow());
560+
prepare(narrow: const CombinedFeedNarrow());
561561
store.addStreams([stream1, stream2]);
562562
store.addSubscription(eg.subscription(stream1));
563563
store.addUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
@@ -922,7 +922,7 @@ void checkInvariants(MessageListView model) {
922922

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

test/widgets/action_sheet_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ void main() {
439439
));
440440
});
441441

442-
testWidgets('not offered in AllMessagesNarrow (composing to reply is not yet supported)', (WidgetTester tester) async {
442+
testWidgets('not offered in CombinedFeedNarrow (composing to reply is not yet supported)', (WidgetTester tester) async {
443443
final message = eg.streamMessage();
444-
await setupToMessageActionSheet(tester, message: message, narrow: const AllMessagesNarrow());
444+
await setupToMessageActionSheet(tester, message: message, narrow: const CombinedFeedNarrow());
445445
check(findQuoteAndReplyButton(tester)).isNull();
446446
});
447447
});

0 commit comments

Comments
 (0)