Skip to content

Commit a98779d

Browse files
committed
timeline: use u64 for all the fields of PaginationOutcome
1 parent 182e84c commit a98779d

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

crates/matrix-sdk-ui/src/timeline/pagination.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use std::{fmt, ops::ControlFlow, sync::Arc, time::Duration};
1616

1717
use matrix_sdk::event_cache::{self, BackPaginationOutcome};
18-
use tracing::{debug, instrument, trace, warn};
18+
use tracing::{instrument, trace, warn};
1919

2020
use crate::timeline::inner::TimelineEnd;
2121

@@ -62,28 +62,13 @@ impl super::Timeline {
6262
return Ok(());
6363
}
6464

65-
let mut update_outcome = || {
66-
outcome.events_received = num_events.try_into().ok()?;
67-
outcome.total_events_received = outcome
68-
.total_events_received
69-
.checked_add(outcome.events_received)?;
70-
71-
outcome.items_added = handle_many_res.items_added;
72-
outcome.items_updated = handle_many_res.items_updated;
73-
outcome.total_items_added += outcome.items_added;
74-
outcome.total_items_updated += outcome.items_updated;
75-
76-
Some(())
77-
};
78-
79-
if update_outcome().is_none() {
80-
// Overflow: stop here and exit.
81-
debug!(
82-
"Hit overflow, stopping back-paginating and getting back to idle."
83-
);
84-
self.back_pagination_status.set_if_not_eq(BackPaginationStatus::Idle);
85-
return Ok(());
86-
}
65+
outcome.events_received = num_events as u64;
66+
outcome.total_events_received += outcome.events_received;
67+
68+
outcome.items_added = handle_many_res.items_added;
69+
outcome.items_updated = handle_many_res.items_updated;
70+
outcome.total_items_added += outcome.items_added;
71+
outcome.total_items_updated += outcome.items_updated;
8772

8873
if num_events == 0 {
8974
// As an exceptional contract: if there were no events in the response,
@@ -242,7 +227,7 @@ impl<'a> fmt::Debug for PaginationOptions<'a> {
242227
#[non_exhaustive]
243228
pub struct PaginationOutcome {
244229
/// The number of events received in last pagination response.
245-
pub events_received: u16,
230+
pub events_received: u64,
246231

247232
/// The number of timeline items added by the last pagination response.
248233
pub items_added: u64,
@@ -252,7 +237,7 @@ pub struct PaginationOutcome {
252237
pub items_updated: u64,
253238

254239
/// The number of events received by a `paginate_backwards` call so far.
255-
pub total_events_received: u16,
240+
pub total_events_received: u64,
256241

257242
/// The total number of items added by a `paginate_backwards` call so
258243
/// far.

0 commit comments

Comments
 (0)