fix(web): #268 multiple new projects bug#287
Conversation
Set default value of users.email_verified column to false via migration
👷 Deploy request for appcut pending review.Visit the deploys page to approve it
|
|
@simonorzel26 is attempting to deploy a commit to the OpenCut OSS Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe code refactors the project initialization logic within the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EditorComponent
participant ProjectLoader
participant Router
User->>EditorComponent: Navigates to /editor/[project_id]
EditorComponent->>EditorComponent: Check if projectId is handled or active
alt projectId not handled and not active
EditorComponent->>ProjectLoader: Attempt to load project
alt Load succeeds
ProjectLoader-->>EditorComponent: Project loaded
else Load fails
EditorComponent->>EditorComponent: Mark projectId as handled
EditorComponent->>ProjectLoader: Create new "Untitled Project"
ProjectLoader-->>EditorComponent: New project created
EditorComponent->>Router: Replace route with new project's editor URL
end
else
EditorComponent->>EditorComponent: Do nothing
end
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/src/app/editor/[project_id]/page.tsx (1)
38-38: Consider memory management for the handledProjectIds ref.The ref effectively prevents redundant project loading attempts, which addresses the multiple new projects bug. However, the Set could grow indefinitely in long-running sessions.
Consider adding a cleanup mechanism or size limit:
-const handledProjectIds = useRef<Set<string>>(new Set()); +const handledProjectIds = useRef<Set<string>>(new Set()); + +// Optional: Add cleanup effect to prevent memory leaks +useEffect(() => { + return () => { + handledProjectIds.current.clear(); + }; +}, []);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/src/app/editor/[project_id]/page.tsx(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/src/app/editor/[project_id]/page.tsx (2)
apps/web/src/hooks/use-playback-controls.ts (1)
usePlaybackControls(6-173)apps/web/src/lib/storage/storage-service.ts (1)
loadProject(71-87)
🔇 Additional comments (4)
apps/web/src/app/editor/[project_id]/page.tsx (4)
3-4: LGTM: Necessary imports added for the bug fix.The addition of
useRefanduseRouterimports are correctly added to support the new project initialization logic.
36-36: LGTM: Router initialization for error handling.The router instance is correctly initialized to handle navigation when project loading fails.
43-66: LGTM: Solid implementation of the bug fix with proper error handling.The refactored initialization logic effectively addresses the multiple new projects bug by:
- Implementing early returns to prevent redundant processing
- Tracking handled project IDs to avoid infinite loops
- Gracefully handling load failures by creating a new project and redirecting
The error handling flow is particularly well-designed: when a project fails to load, it marks the ID as handled, creates a new "Untitled Project", and redirects to prevent further attempts.
67-67: LGTM: Dependency array correctly updated.The dependency array properly includes
activeProject?.idandrouterto ensure the effect runs when the active project changes or when the router instance changes.
…-new-projects fix(web): OpenCut-app#268 multiple new projects bug
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Fixes # (issue)
The useEffect was looping and creating many projects due to unhandled cases.
I fix this bug by dissecting the ternerary and guard clause each case seperately. Then try to load the project, when project is non existant, create new project and redirect there.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Tested every way to make and load a new project
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Screenshots (if applicable)
Add screenshots to help explain your changes.
Checklist:
Additional context
Add any other context about the pull request here.
Summary by CodeRabbit