Skip to content

Commit 61a2319

Browse files
committed
msglist [nfc]: Add public renarrowAndFetch method, and use internally
We'll use this in keyword search, coming up, for renarrowing when the user submits a new keyword.
1 parent 38714de commit 61a2319

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/model/message_list.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,19 @@ class MessageListView with ChangeNotifier, _MessageSequence {
614614

615615
/// The narrow shown in this message list.
616616
///
617-
/// This can change over time, notably if showing a topic that gets moved.
617+
/// This can change over time, notably if showing a topic that gets moved,
618+
/// or if [renarrowAndFetch] is called.
618619
Narrow get narrow => _narrow;
619620
Narrow _narrow;
620621

622+
/// Set [narrow] to [newNarrow], reset, [notifyListeners], and [fetchInitial].
623+
void renarrowAndFetch(Narrow newNarrow) {
624+
_narrow = newNarrow;
625+
_reset();
626+
notifyListeners();
627+
fetchInitial();
628+
}
629+
621630
/// The anchor point this message list starts from in the message history.
622631
///
623632
/// This is passed to the server in the get-messages request
@@ -1101,10 +1110,7 @@ class MessageListView with ChangeNotifier, _MessageSequence {
11011110
switch (propagateMode) {
11021111
case PropagateMode.changeAll:
11031112
case PropagateMode.changeLater:
1104-
_narrow = newNarrow;
1105-
_reset();
1106-
notifyListeners();
1107-
fetchInitial();
1113+
renarrowAndFetch(newNarrow);
11081114
case PropagateMode.changeOne:
11091115
}
11101116
}

0 commit comments

Comments
 (0)