Hey 👋
I imported quite a lot of bookmarks and annotations to Margin. Since then, I can't see any of the annotations and bookmarks I previously made using Margin on my profile (or on /bookmarks or /annotations). The records still exist, so it's probably some issue with sorting/ordering/indexing somewhere.
Update
Okay. I just did some inspection at the code on my phone while in the train and I have findings to share. There's two issues. Both issues occur only when (1) the user is seeing their own feed; and (2) the user is logged in. This is because the user's own feed is provided by serveUserFeedFromPDS when logged in.
(a) Wrong ordering of items
serveUserFeedFromPDS relies on listRecords, which sorts by TID.
- When the user imports older bookmarks, chances are the TIDs are still based on newer dates, meaning they will show up first.
I see two possible solutions:
- Live with it and don't do anything
- Just provide the user's own feed from the database.
I prefer 2 for consistency, and that would also fix the next issue.
(b) Missing items
listRecords uses a cursor for pagination. serveUserFeedFromPDS goes around this by using a larger limit (limit + offset).
- On the frontend,
hasMore is defined if items >= items.length.
- That's a problem. The PDS may not always return as many items as in the limit, even if there are more afterwards. That's why it returns a
cursor to tell if there's more.
- This also means that every time the user presses "Load more", all previous items are fetched, plus the new ones (on the backend). That can become a strain once there's thousands of items.
Possible solutions:
- Just use the database normally. The current situation is also probably not scalable once the user has 1000 bookmarks. Are we gonna fetch 1000 bookmarks in one go? This would also solve the previously mentioned issue.
- When the user is logged in, use cursor based pagination. This would involve quite some refactoring.****
Hey 👋
I imported quite a lot of bookmarks and annotations to Margin. Since then, I can't see any of the annotations and bookmarks I previously made using Margin on my profile (or on /bookmarks or /annotations). The records still exist, so it's probably some issue with sorting/ordering/indexing somewhere.
Update
Okay. I just did some inspection at the code on my phone while in the train and I have findings to share. There's two issues. Both issues occur only when (1) the user is seeing their own feed; and (2) the user is logged in. This is because the user's own feed is provided by
serveUserFeedFromPDSwhen logged in.(a) Wrong ordering of items
serveUserFeedFromPDSrelies onlistRecords, which sorts by TID.I see two possible solutions:
I prefer 2 for consistency, and that would also fix the next issue.
(b) Missing items
listRecordsuses a cursor for pagination.serveUserFeedFromPDSgoes around this by using a larger limit (limit + offset).hasMoreis defined ifitems >= items.length.cursorto tell if there's more.Possible solutions: