fix: prevent new project show old media in initial load#465
Conversation
👷 Deploy request for appcut pending review.Visit the deploys page to approve it
|
|
@khanguyen74 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 loading logic in the editor page by removing dependencies on Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant EditorPage
participant ProjectStore
User->>EditorPage: Navigates to /editor/[project_id]
EditorPage->>ProjectStore: loadProject(project_id)
alt Project found
ProjectStore-->>EditorPage: Project data
else Project not found
ProjectStore-->>EditorPage: Error ("not found")
EditorPage->>User: Redirect to /projects
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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)
46-50: Good fix! Consider making error handling more robust.The new error handling correctly addresses the bug by redirecting to the projects list instead of creating a new project that could inherit old media. This is much cleaner than the previous approach.
Consider making the error handling more robust by checking error status codes in addition to message content:
- if (error.message.includes("not found")) { + if (error.message.includes("not found") || error.status === 404) {
📜 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(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build (windows-latest)
🔇 Additional comments (2)
apps/web/src/app/editor/[project_id]/page.tsx (2)
35-35: LGTM! Simplification addresses the core issue.Removing
activeProjectandcreateNewProjectfrom the store destructuring eliminates potential sources of stale state that could cause old media to persist in new projects. This directly addresses the PR objective.
56-56: Dependency array correctly reflects the simplified logic.The updated dependency array properly includes only the values actually used in the effect (
projectId,loadProject,router) and removes dependencies that were causing the old media bug. This should make the effect more predictable and performant.
|
I also have open pr for that issue you can check #427 |
|
Closed in favor of #427 |
Description
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Test Configuration:
Screenshots (if applicable)
Before
Screen.Recording.2025-07-17.at.7.18.06.PM.mov
After
Screen.Recording.2025-07-17.at.7.18.31.PM.mov
Checklist:
Additional context
Add any other context about the pull request here.
Summary by CodeRabbit