-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: handle invites to projects #70
base: main
Are you sure you want to change the base?
Conversation
…accept or reject an invite to a project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only an initial code review and didn't actually try out the feature (can I even do that?).
Upgrading to @comapeo/core-react
to v2 will reduce the diff here a bit. I have a separate PR for that via #85
Didn't take a good look at the test just yet but I think our testing setup needs to be improved in order to make it less tedious to write (Erik had started work on it but I think it's worth revisiting - I had lots of feedback on it and might just work on it myself)
return useSuspenseQuery({ | ||
...pendingInvitesQueryOptions({ clientApi }), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary spread operator
return useSuspenseQuery({ | |
...pendingInvitesQueryOptions({ clientApi }), | |
}) | |
return useSuspenseQuery( | |
pendingInvitesQueryOptions({ clientApi }), | |
) |
import { pendingInvitesQueryOptions, useClientApi } from '@comapeo/core-react' | ||
import { useSuspenseQuery } from '@tanstack/react-query' | ||
|
||
export function usePendingInvites() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to consider having this hook implemented in a way similar to what's outlined in digidem/comapeo-core-react#8, the main difference being adding a listener that invalidates the relevant query cache.
Ideally implementing this yourself isn't needed - but haven't gotten around to doing it yet 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I tried to do this and the dedupe...Will be curious if I did it as you imagined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing if (invite) { ... }
within event handlers and fallbacks in the render body to account for the invite no longer being available is usually a smell to me. Would suggest accounting for the two discrete states explicitly and separately:
- When the invite is no longer available and cannot be responded to
- When the invite is available and can be responded to
Something along the lines of this:
function JoinProjectScreenComponent() {
// Same logic as you currently have for getting the inviteId and all
const invite = pendingInvites.find((i) => i.inviteId === inviteId)
// If the associated invite is no longer available, render content that's specific to that state
if (!invite) {
return <div>...</div>
}
// Otherwise, render the content as though the invite is still valid
return <div>...</div>
}
This becomes less prone to type-related issues and workarounds, as well as a clearer UI. There may be some parts of the screen that are the same in both of the states (duplication is fine IMO), but for example it doesn't make sense to render the buttons if we know that pressing them won't do anything because the invite is no longer valid. Not detailed in the design but I think that's a fair observation 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achou11 I did as you requested, but I also added a Dev feature to be able to simulate an invite... Seen on every screen but it only works on the CreateJoin Project screen. |
Hey, thanks for all the work on this. Gregor and I realized that there are some blockers with this architecture. If we delete CoMapeo on desktop, we don't actually delete the data. This would mean if the user tries to delete CoMapeo in order to get back to the "join a project screen", it would not work. Lets put a pause on this work as we will need to change the design to account for this. Thanks for doing the work and sorry that we caught this a little too late. |
closes #42
Adds files to listen for invites, handle them when they come in, and accept or reject an invite to a project.
Used this notion doc: https://www.notion.so/digidem/Desktop-Invites-Architecture-15a1b08162d58053b27dd7b6133e7e33