refactor(sdk): Remove assume_has_waited_for_initial_prev_token.

This patch removes the `assume_has_waited_for_initial_prev_token` by
making `waited_for_initial_prev_token` to return a `&mut bool` instead
of `bool`.
This commit is contained in:
Ivan Enderlin
2026-02-10 10:35:34 +01:00
parent 72c1a655f2
commit df6fc21576
2 changed files with 5 additions and 10 deletions

View File

@@ -186,7 +186,7 @@ impl RoomPagination {
match state_guard.load_more_events_backwards().await? {
LoadMoreEventsBackwardsOutcome::Gap { prev_token } => {
if prev_token.is_none() && !state_guard.waited_for_initial_prev_token() {
if prev_token.is_none() && !*state_guard.waited_for_initial_prev_token() {
// We didn't reload a pagination token, and we haven't waited for one; wait
// and start over.
@@ -205,7 +205,7 @@ impl RoomPagination {
.await;
trace!("done waiting");
self.inner.state.write().await?.assume_has_waited_for_initial_prev_token();
*self.inner.state.write().await?.waited_for_initial_prev_token() = true;
// Retry!
//

View File

@@ -1258,13 +1258,8 @@ mod private {
}
/// Get the `waited_for_initial_prev_token` value.
pub fn waited_for_initial_prev_token(&self) -> bool {
self.state.waited_for_initial_prev_token
}
/// Assume the system has already waited for the initial `prev_token`.
pub fn assume_has_waited_for_initial_prev_token(&mut self) {
self.state.waited_for_initial_prev_token = true;
pub fn waited_for_initial_prev_token(&mut self) -> &mut bool {
&mut self.state.waited_for_initial_prev_token
}
/// Find a single event in this room.
@@ -1712,7 +1707,7 @@ mod private {
// If we've never waited for an initial previous-batch token, and we've now
// inserted a gap, no need to wait for a previous-batch token later.
if !self.state.waited_for_initial_prev_token && has_new_gap {
self.assume_has_waited_for_initial_prev_token();
self.state.waited_for_initial_prev_token = true;
}
// Remove the old duplicated events.