-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: resolve GitHub profile pictures and recent projects refresh issues #2773
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -36,13 +36,22 @@ export const useStartProject = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
await apiUtils.project.createRequest.getPendingRequest.invalidate({ projectId: editorEngine.projectId }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const { mutateAsync: trackProjectAccess } = api.project.trackAccess.useMutation({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
onSuccess: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Invalidate project list to refresh recent projects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
apiUtils.project.list.invalidate(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (project) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
startSandbox(project); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
editorEngine.screenshot.lastScreenshotAt = project.metadata.updatedPreviewImgAt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Track project access to update "recent projects" list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
trackProjectAccess({ projectId: project.id }).catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [project]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, [project, trackProjectAccess]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+51
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Guard against duplicate tracking on re-renders Depending on the identity stability of Apply this diff in the nearest appropriate scopes: +import { useEffect, useRef, useState } from 'react'; - useEffect(() => {
- if (project) {
- startSandbox(project);
- editorEngine.screenshot.lastScreenshotAt = project.metadata.updatedPreviewImgAt;
- // Track project access to update "recent projects" list
- trackProjectAccess({ projectId: project.id }).catch(console.error);
- }
- }, [project, trackProjectAccess]);
+ const lastTrackedProjectIdRef = useRef<string | null>(null);
+ useEffect(() => {
+ if (project) {
+ startSandbox(project);
+ editorEngine.screenshot.lastScreenshotAt = project.metadata.updatedPreviewImgAt;
+ // Track project access to update "recent projects" list (once per project id)
+ if (lastTrackedProjectIdRef.current !== project.id) {
+ lastTrackedProjectIdRef.current = project.id;
+ void trackProjectAccess({ projectId: project.id }).catch(console.error);
+ }
+ }
+ }, [project?.id]); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const startSandbox = async (project: Project) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ export const userRouter = createTRPCRouter({ | |
lastName: user.lastName ?? lastName, | ||
displayName: user.displayName ?? displayName, | ||
email: user.email ?? authUser.email, | ||
avatarUrl: user.avatarUrl ?? authUser.user_metadata.avatarUrl, | ||
avatarUrl: user.avatarUrl ?? authUser.user_metadata.avatar_url, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @binu-baiju Thanks for the PR! There seems to be a lot of your personal config changes. I think this is the only thing we need. Could you remove the rest? Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kitenite Sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}) : null; | ||
return userData; | ||
}), | ||
|
@@ -56,7 +56,7 @@ export const userRouter = createTRPCRouter({ | |
lastName: input.lastName ?? lastName, | ||
displayName: input.displayName ?? displayName, | ||
email: input.email ?? authUser.email, | ||
avatarUrl: input.avatarUrl ?? authUser.user_metadata.avatarUrl, | ||
avatarUrl: input.avatarUrl ?? authUser.user_metadata.avatar_url, | ||
}; | ||
|
||
const [user] = await ctx.db | ||
|
Uh oh!
There was an error while loading. Please reload this page.