Closed cha0sg0d closed 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
nym | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 12, 2023 4:01pm |
This looks a lot cleaner, good stuff. Small thing, but I think fetch parents should be aligned left (similar to how reddit does it) see u have it in the TODOs though so all good
Additional bugs fixed in this PR:
Post Highlighting on deep linking:
https://github.com/personaelabs/nym/assets/95446735/d6a3d7ab-f7f2-4160-81ec-93bd42382137
Description:
This PR builds on and simplifies Amir's initial PR for threading deeply nested posts and deep linking to deeply nested posts. There was a lot of code that we could remove because in the schema described below, we never have to recursively iterate AND fetch posts at the same time in the frontend (like how we previously displayed a deeply linked post). Instead, we have two building blocks -- fetching deeper replies and fetching parents -- that have relatively simple logic for how the data is fetched and rendered on the frontend.
https://share.cleanshot.com/Jrqs0lBZ
This video shows going deeply into a nested thread, copying a link, opening that link in a new tab, then fetching the parents of that nested post back up to the root.
Threading deeply nested posts
Each item in the thread can fetch replies below it. We fetch the number of children a post has AND the actual children objects. If the number of children a post has is greater than the number of children objects (like when our recursive query ended and there are no more children fetched), that item can fetch its children. It appends it's children to itself using the same recursive threading logic.
Deep Linking deeply nested posts
If a post has a depth greater than a specified depth (for now, 5), we don't render it's parents on the client initially. We simply render the root, the post in question, and any children the post has (up to specified depth). To view that post's parents, we have a
fetch parents
function that goes updepth
levels on the tree, then performs the traditional recursive fetch of a post and it's replies. On the frontend, when a post's parent (or grandparent etc...) is fetched, we replace our entire thread with the new parent and it's children, which will include the original post.Additional Utilities
TODO:
Smaller Things I'd like to do:
PostWithReplies.tsx
, figure out a better way to namesinglePost
(the post a page is loaded with) andparent
(the post the page is replaced with when parents are fetched)[parent]
orsinglePost.replies
toresolveNestedReplyThreads
.[postId].ts
, get the post root as part of thepostSelect
query to avoid two database calls.getRootAndPostIdFromPreview
in backend.parent
property to theParentPostPayload
typesinglePost.root
inPostWithReplies.tsx