fix token when returning from preview on shares with pass#2588
Conversation
📝 WalkthroughWalkthroughThe ChangesShare Info Mutation Fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Related issues: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/store/mutations.js (1)
1073-1080: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider a shared merge helper to avoid future drift.
setShareInfoandsetShareDatanow both implement a "merge-with-existing-state + JSON.stringify equality check" pattern independently, withsetShareInfoadditionally special-casingtoken/passwordValid. Extracting a sharedmergeShareState(existing, incoming, preserveKeys)helper would prevent the two mutations from silently diverging again (as happened here, triggering the original bug).♻️ Example shared helper
+function mergeShareState(existing, incoming, preserveKeys = []) { + const merged = { ...existing, ...incoming }; + for (const key of preserveKeys) { + if (incoming[key] === undefined && existing[key] !== undefined) { + merged[key] = existing[key]; + } + } + return merged; +}Then both mutations can call
mergeShareState(state.shareInfo, shareInfo, ['token', 'passwordValid'])/mergeShareState(state.shareInfo, shareData).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/store/mutations.js` around lines 1073 - 1080, `setShareInfo` and `setShareData` duplicate the same merge-and-compare logic, which risks them drifting apart again. Extract the shared merge behavior from the mutations in `mutations.js` into a helper like `mergeShareState(existing, incoming, preserveKeys)` and have both `setShareInfo` and `setShareData` use it; keep the `token` and `passwordValid` preservation currently handled in `setShareInfo` via the helper’s preserve list, and leave the existing JSON.stringify equality check centralized there as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@frontend/src/store/mutations.js`:
- Around line 1073-1080: `setShareInfo` and `setShareData` duplicate the same
merge-and-compare logic, which risks them drifting apart again. Extract the
shared merge behavior from the mutations in `mutations.js` into a helper like
`mergeShareState(existing, incoming, preserveKeys)` and have both `setShareInfo`
and `setShareData` use it; keep the `token` and `passwordValid` preservation
currently handled in `setShareInfo` via the helper’s preserve list, and leave
the existing JSON.stringify equality check centralized there as well.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b1dd17cb-f843-4527-8c8f-ede148641a1e
📒 Files selected for processing (1)
frontend/src/store/mutations.js
Fixes #2573
Summary by CodeRabbit