Skip to content

Commit

Permalink
Skip link header if it is the final page
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Nov 5, 2024
1 parent 43bb7ac commit d7073c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions megalodon/src/friendica.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ export default class Friendica implements MegalodonInterface {
converted = Object.assign({}, converted, {
data: [...converted.data, ...nextRes.data.map(a => FriendicaAPI.Converter.account(a))]
})
if (nextRes.headers.link === undefined) {
break
}
parsed = parseLinkHeader(nextRes.headers.link)
if (sleep_ms) {
await new Promise<void>(converted => setTimeout(converted, sleep_ms))
Expand Down
3 changes: 3 additions & 0 deletions megalodon/src/mastodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ export default class Mastodon implements MegalodonInterface {
converted = Object.assign({}, converted, {
data: [...converted.data, ...nextRes.data.map(a => MastodonAPI.Converter.account(a))]
})
if (nextRes.headers.link === undefined) {
break
}
parsed = parseLinkHeader(nextRes.headers.link)
if (sleep_ms) {
await new Promise<void>(converted => setTimeout(converted, sleep_ms))
Expand Down

0 comments on commit d7073c6

Please sign in to comment.