Skip to content

Commit

Permalink
Merge pull request #494 from ramsayleung/ramsay/fix-endless-sequence
Browse files Browse the repository at this point in the history
[fix] Fix endless sequential pagination
  • Loading branch information
ramsayleung authored Sep 13, 2024
2 parents 47e388b + 447e519 commit 07dc031
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
**Breaking changes**
- ([#487](https://github.com/ramsayleung/rspotify/pull/487)) Change the type of `TrackLink.id` from `TrackId<'static>` to `Option<TrackId<'static>>`

**Bugfixes**
- ([#494](https://github.com/ramsayleung/rspotify/pull/494)) Fix endless sequential pagination problem.

## 0.13.3 (2024.08.24)
**New features**
- ([#490](https://github.com/ramsayleung/rspotify/pull/490)) Add impls for `Clone`, `Debug`, `PartialEq`, `Eq`, `Serialize` and `Hash` for `PlayContextId` and `PlayableId`
Expand Down
6 changes: 6 additions & 0 deletions src/clients/pagination/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ where
let request = req(&ctx, page_size, offset);
let page = request.await?;
offset += page.items.len() as u32;
// Occasionally, the Spotify will return an empty items with non-none next page
// So we have to check both conditions
// https://github.com/ramsayleung/rspotify/issues/492
if page.items.is_empty() {
break;
}
for item in page.items {
yield Ok(item);
}
Expand Down

0 comments on commit 07dc031

Please sign in to comment.