Skip to content

Commit a278a7d

Browse files
committed
msglist [nfc]: Return early if generation has changed
Signed-off-by: Zixuan James Li <[email protected]>
1 parent e53e8b8 commit a278a7d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/model/message_list.dart

+9-4
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,16 @@ class MessageListView with ChangeNotifier, _MessageSequence {
530530
_insertAllMessages(0, fetchedMessages);
531531
_haveOldest = result.foundOldest;
532532
} finally {
533-
if (this.generation == generation) {
534-
_fetchingOlder = false;
535-
_updateEndMarkers();
536-
notifyListeners();
533+
if (this.generation != generation) {
534+
// We need the finally block always clean up regardless of errors
535+
// occured in the try block, and returning early here is necessary
536+
// if such cleanup must be skipped, as the fetch is considered stale.
537+
// ignore: control_flow_in_finally
538+
return;
537539
}
540+
_fetchingOlder = false;
541+
_updateEndMarkers();
542+
notifyListeners();
538543
}
539544
}
540545

0 commit comments

Comments
 (0)