powerhouse-inc / connect

https://document-model-electron.vercel.app
3 stars 3 forks source link

feat: simplify tree view #454

Closed ryanwolhuter closed 1 month ago

ryanwolhuter commented 1 month ago

Now that we have the UiNodesContext from the design system, we can use it in connect. This allows us to delete a ton of code.

NOTE: github says there are thousands of lines added. This is because I wrapped a bunch of functions in useCallback, which github thinks means I modified the entire functions, but they are actually unchanged.

The biggest changes are:

Business logic relating to nodes now all lives in a hook called useUiNodes. This hook handles all of the logic related to nodes in the ui, which means whenever we need to do node-related stuff we can just use this one hook. The hook also returns the return values of the other hooks that have logic for nodes, such as useDocumentDriveServer and useUserPermissions. This means we don't need to invoke multiple hooks to get these functions and data, which reduces code duplication by a lot.

Handling the url is now done in the useNodeNavigation hook. This hook reacts to changes in the selected node and updates the url accordingly, which means we do not need to worry about updating the url ourselves as before. This also means that the browser back and forward buttons work seamlessly. I have added a basic slug generation function that runs only on file and folder nodes and generates a slug from the node name. This slug does not need to be persisted by the document drive, because we simply generate this slug when we load the nodes.

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
connect ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 1:29pm
github-actions[bot] commented 1 month ago

:tada: This PR is included in version 1.0.0-dev.47 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 month ago

:tada: This PR is included in version 1.0.0-next.6 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: