-
Notifications
You must be signed in to change notification settings - Fork 212
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
remember last workspace visited by user #271
Conversation
6aa5489
to
feaba15
Compare
workspaces.data.find((workspace) => workspace.ownerId === user.id) ?? | ||
workspaces.data[0] | ||
if (workspace) { | ||
router.replace(`/workspaces/${workspaces.data[0].id}/documents`) |
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.
Can't workspaces.data[0]
be undefined, technically speaking? Shouldn't we have kept that length
check above?
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.
This is a bug, it should use workspace.id
const workspace = | ||
data.find( | ||
(workspace) => workspace.id === session.data?.lastVisitedWorkspaceId | ||
) ?? | ||
data.find((workspace) => workspace.ownerId === session.data?.id) ?? | ||
data[0] |
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.
Probably not something for this PR, but it's kind of annoying that we have to have very similar code here and in the session redirect.
ALTER TABLE "User" ADD COLUMN "lastVisitedWorkspaceId" UUID; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "User" ADD CONSTRAINT "User_lastVisitedWorkspaceId_fkey" FOREIGN KEY ("lastVisitedWorkspaceId") REFERENCES "Workspace"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
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.
Can we make this migration set the first value of lastVisitedWorkspaceId
as the latest workspace this user created? If that doesn't exist, we could just set it to the earliest workspace.
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.
The source code will default to one he is owner of
feaba15
to
c3f09f1
Compare
No description provided.