videah / SkyBridge

A work in progress bridge/proxy that lets you use Mastodon apps with Bluesky
https://skybridge.fly.dev
MIT License
532 stars 34 forks source link

timeline backfilling/pagination support #18

Closed Treeki closed 1 year ago

Treeki commented 1 year ago

This is a first draft of support for backfilling and paginating timelines so that viewing tweets toots posts skeets in Ivory is a more comfortable experience.


Requests to the home timeline with a min_id specified (and no max_id or since_id) are treated as "I want the latest posts", and it tries to fetch as many as possible and deliver them in one request, using the same logic that I wrote for BirdBridge (https://github.com/Treeki/BirdBridge/blob/main/main.ts#L129-L207).

I also generate a Link header to make Ivory happy - this gets rid of the issue where it's perpetually stuck in a loading state and won't allow you to manually refresh or show the amount of unread posts.


What's still missing:


Using the 'next' links is tricky because Bluesky requires cursors.

In theory you could ignore max_id and just supply the cursor as a non-standard parameter in the rel="next" link, but I haven't tested if this will work with Ivory.

I know that rel="prev" links definitely need to follow the standard format for Ivory to work correctly (as it will try to generate its own in certain cases, based off its newest known post ID) but I don't think they do the same for rel="prev". It's probably worth a try at least!

Tried this and it works, so that technique seems viable - I can now scroll further down in the timeline!

felixmueller commented 1 year ago

@videah @Treeki +1️⃣ for merging this PR if it's working! Finally a fixed loading indicator and refresh function in Ivory 👌