Bookmarks #2170

Closed
eugenijm wants to merge 5 commits from gitlab-mr-iid-903 into develop
Member

Revives the bookmarks MR (Closes #472).

  • pagination needs to be updated to be compatible with the current BE implementation, which stores bookmarks in a separate table in the DB (ref: #667).
Revives [the bookmarks MR](https://git.pleroma.social/pleroma/pleroma-fe/pulls/2021) (Closes #472). - [x] pagination needs to be updated to be compatible with the current BE implementation, which stores bookmarks in a separate table in the DB (ref: https://git.pleroma.social/pleroma/pleroma-fe/issues/667).
Member

Please update the pagination and resolve the WIP status and I will test and review it.

Please update the pagination and resolve the WIP status and I will test and review it.
Author
Member

Done, ready for review

Done, ready for review
Member

what is that and why is it needed

what is that and why is it needed
Member
      return this.status.bookmarked ? 'icon-bookmark' : 'icon-bookmark-empty'
```suggestion:-0+3 return this.status.bookmarked ? 'icon-bookmark' : 'icon-bookmark-empty' ```
Member

doesn't belong here, i doubt people will use it often so it's better in three-dots menu instead

doesn't belong here, i doubt people will use it often so it's better in three-dots menu instead
Member
  // Note: BE doesn't order bookmarks by their status ids and doing so here would break pagination.
```suggestion:-0+0 // Note: BE doesn't order bookmarks by their status ids and doing so here would break pagination. ```
Member

not liking the "meta" name... how about we use preserveOrder boolean that will disable sorting (also removes ugly timeline !== 'bookmarks') and forces it to use maxId/minId from array's head and tail instead of minBy/maxBy

not liking the "meta" name... how about we use `preserveOrder` boolean that will disable sorting (also removes ugly `timeline !== 'bookmarks'`) and forces it to use maxId/minId from array's head and tail instead of minBy/maxBy
Member

report error in console?

report error in console?
Author
Member

On BE, bookmarks are represented by a different table, and their ids are only available via the Link header (https://web.archive.org/web/20191119161310/https://docs.joinmastodon.org/api/rest/statuses/#pagination). The http-link-header lib is for parsing it.

EDIT: Mastodon broke the link

On BE, bookmarks are represented by a different table, and their ids are only available via the Link header (https://web.archive.org/web/20191119161310/https://docs.joinmastodon.org/api/rest/statuses/#pagination). The `http-link-header` lib is for parsing it. EDIT: Mastodon broke the link
Author
Member

We still need maxId/minId from the Link header because they are referring to a different table which represents bookmarks on BE. The good thing is that having prev/next page in the Link header is a part of Mastodon TL API and so we don't have to introduce special case. But we still need to pass the ids from apiService.fetchTimeline to addNewStatuses to make use of them; I'm not sure if there is a way to avoid it without affecting the bookmarks TL.

We still need maxId/minId from the Link header because they are referring to a different table which represents bookmarks on BE. The good thing is that having prev/next page in the Link header is a part of Mastodon TL API and so we don't have to introduce special case. But we still need to pass the ids from `apiService.fetchTimeline` to `addNewStatuses` to make use of them; I'm not sure if there is a way to avoid it without affecting the bookmarks TL.
Owner

Are we bookmark ready yet?

Are we bookmark ready yet?
Member

What's the status on this? May I take over and finish it?

What's the status on this? May I take over and finish it?
Member

i need to re-check it and test it, basically

i need to re-check it and test it, basically
Member

Now that there are emoji reactions, the UI probably needs to be changed a bit..

Now that there are emoji reactions, the UI probably needs to be changed a bit..
First-time contributor

Shouldn't this also be present for other ~timelines? The bookmark pagination isn't really that specific other than with the ordering that needs to be preserved.

Shouldn't this also be present for other ~timelines? The bookmark pagination isn't really that specific other than with the ordering that needs to be preserved.
Author
Member

Right now, the prev/next ids are taken from the status list from the response body by calculating min/max status ids. This doesn't work for bookmarks since /api/v1/bookmarks returns a list of statuses, and their ids cannot be used for paginating bookmarks (but link headers containing bookmarks ids can).

In the MR, the change applies to other timelines too for consistency (prev/next ids are taken from link headers instead of status list from the response body).

Right now, the prev/next ids are taken from the status list from the response body by calculating min/max status ids. This doesn't work for bookmarks since `/api/v1/bookmarks` returns a list of statuses, and their ids cannot be used for paginating bookmarks (but link headers containing bookmarks ids can). In the MR, the change applies to other timelines too for consistency (prev/next ids are taken from link headers instead of status list from the response body).
Member

the change applies to other timelines too for consistency

thanks for mentioning, that's something that needs to be tested also.

>the change applies to other timelines too for consistency thanks for mentioning, that's something that needs to be tested also.
Member

we used this for the exact same purpose in pleroma-api: https://bundlephobia.com/result?p=parse-link-header@1.0.1

about 3 times smaller

we used this for the exact same purpose in pleroma-api: https://bundlephobia.com/result?p=parse-link-header@1.0.1 about 3 times smaller
Member

The pagination implementation itself seems to work right on timelines

The pagination implementation itself seems to work right on timelines
Member

what's going on in here? this breaks the public timeline icon (zoom-in and users icon have the same code, so the public timeline icon is replaced by the zoom-in icon)

what's going on in here? this breaks the public timeline icon (zoom-in and users icon have the same code, so the public timeline icon is replaced by the zoom-in icon)
Author
Member

that must be a rebase leftover, sorry, fixed it

that must be a rebase leftover, sorry, fixed it
Member

I did some more testing, just observing the same timeline on this branch and on my instance without it, for some reason in this branch it triggers the timeline "flush" much more often for no good reason. on my twkn it went from "Show new (6)" on both tabs to "Show new (8)" in one and "Show new" (flush queued) in this branch. 2 new posts should never trigger a flush

I did some more testing, just observing the same timeline on this branch and on my instance without it, for some reason in this branch it triggers the timeline "flush" much more often for no good reason. on my twkn it went from "Show new (6)" on both tabs to "Show new (8)" in one and "Show new" (flush queued) in this branch. 2 new posts should never trigger a flush
Member

if I let it sit, every single fetch triggers the flush, something is wrong with the since_id since the request returns 20 posts but much less is actually added to the timeline, so it contains a bunch of duplicates

if I let it sit, every single fetch triggers the flush, something is wrong with the since_id since the request returns 20 posts but much less is actually added to the timeline, so it contains a bunch of duplicates
Member

after an hour or two of debugging or so, I found the bug lol

after an hour or two of debugging or so, I found the bug lol
Member

how reasonable would unit tests be for his function? it's pure at least

how reasonable would unit tests be for his function? it's pure at least
Member

marking this thread as resolved, bug found at #2170

marking this thread as resolved, bug found at https://git.pleroma.social/pleroma/pleroma-fe/pulls/2170?diff_id=14929#note_65960
Author
Member

ah, nice catch! sure, will write a unit test soon

ah, nice catch! sure, will write a unit test soon
Author
Member

added the unit tests

added the unit tests
Member

maybe we should have some sort of explanation why we put maxId into minNew

maybe we should have some sort of explanation why we put maxId into minNew
Member

fetchAndUpdate doesn't seem to take pagination object at all

fetchAndUpdate doesn't seem to take pagination object at all
Member

functionality wise now both bookmarking and timelines seem to work just right 👍

I'll still do a bit more side-by-side testing with this vs old to make sure things work the same

functionality wise now both bookmarking and timelines seem to work just right :thumbsup: I'll still do a bit more side-by-side testing with this vs old to make sure things work the same
Member

I think something as simple as

  // Mismatch between API pagination and our internal minId/maxId tracking systems:
  // pagination.maxId is the oldest of the returned statuses when fetching older,
  // and pagination.minId is the newest when fetching newer. The names come directly
  // from the arguments they're supposed to be passed as for the next fetch.

might do

I think something as simple as ``` // Mismatch between API pagination and our internal minId/maxId tracking systems: // pagination.maxId is the oldest of the returned statuses when fetching older, // and pagination.minId is the newest when fetching newer. The names come directly // from the arguments they're supposed to be passed as for the next fetch. ``` might do
Author
Member

Thanks, sounds very good, added the explanation

Thanks, sounds very good, added the explanation

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
7 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pleroma/pleroma-fe!2170
No description provided.