personaelabs / noun-nyms

https://nouns.nymz.xyz
MIT License
14 stars 1 forks source link

Threading v2 #178

Closed cha0sg0d closed 1 year ago

cha0sg0d commented 1 year ago

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 up depth 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:

vercel[bot] commented 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
amirgamil commented 1 year ago

This looks a lot cleaner, good stuff. Small thing, but I think fetch parents should be aligned left (similar to how reddit does it) Screenshot 2023-06-10 at 6 34 17 PM see u have it in the TODOs though so all good

grace-fagan commented 1 year ago

Additional bugs fixed in this PR:

grace-fagan commented 1 year ago

Post Highlighting on deep linking:

https://github.com/personaelabs/nym/assets/95446735/d6a3d7ab-f7f2-4160-81ec-93bd42382137