Skip to content

Commit

Permalink
Fix breaking too early when restoring tweet
Browse files Browse the repository at this point in the history
  • Loading branch information
robertodoering committed Nov 26, 2022
1 parent 1d99fdb commit 723ce16
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/components/timeline/provider/timeline_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ abstract class TimelineNotifier<T extends Object>
TweetData? restoredTweet;
int? restoredTweetIndex;

// find the tweet with `tweetId`, or the the next tweet that is newer that
// `tweetId`
for (var i = 0; i < tweets.length; i++) {
final id = int.tryParse(tweets[i].originalId);
if (id != null && id >= tweetId) {
if (id == null) continue;

if (id >= tweetId) {
restoredTweet = tweets[i];
restoredTweetIndex = i;
} else {
break;
}
}
Expand Down

0 comments on commit 723ce16

Please sign in to comment.