Skip to content

Commit

Permalink
ui: Add loading indicator before waiting for prev_batch token
Browse files Browse the repository at this point in the history
… in Timeline::paginate_backwards.
  • Loading branch information
jplatte committed Jun 14, 2023
1 parent b4fdfee commit b4cd0c7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,27 @@ impl Timeline {
#[instrument(skip_all, fields(room_id = ?self.room().room_id(), ?options))]
pub async fn paginate_backwards(&self, mut options: PaginationOptions<'_>) -> Result<()> {
let mut start_lock = self.start_token.lock().await;
if start_lock.is_none() {
if self.inner.items().await.front().is_some_and(|item| item.is_timeline_start()) {
warn!("Start of timeline reached, ignoring backwards-pagination request");
return Ok(());
}
if start_lock.is_none()
&& self.inner.items().await.front().is_some_and(|item| item.is_timeline_start())
{
warn!("Start of timeline reached, ignoring backwards-pagination request");
return Ok(());
}

if options.wait_for_token {
info!("No prev_batch token, waiting");
(start_lock, _) = self
.start_token_condvar
.wait_timeout_until(start_lock, Duration::from_secs(3), |tok| tok.is_some())
.await;
self.inner.add_loading_indicator().await;

if start_lock.is_none() {
debug!("Waiting for prev_batch token timed out after 3s");
}
if start_lock.is_none() && options.wait_for_token {
info!("No prev_batch token, waiting");
(start_lock, _) = self
.start_token_condvar
.wait_timeout_until(start_lock, Duration::from_secs(3), |tok| tok.is_some())
.await;

if start_lock.is_none() {
debug!("Waiting for prev_batch token timed out after 3s");
}
}

self.inner.add_loading_indicator().await;

let mut from = start_lock.clone();
let mut outcome = PaginationOutcome::new();

Expand Down

0 comments on commit b4cd0c7

Please sign in to comment.