Skip to content

fix token when returning from preview on shares with pass#2588

Merged
gtsteffaniak merged 1 commit into
dev/v1.5.1from
fix/token-shares-with-pass
Jul 2, 2026
Merged

fix token when returning from preview on shares with pass#2588
gtsteffaniak merged 1 commit into
dev/v1.5.1from
fix/token-shares-with-pass

Conversation

@Kurami32

@Kurami32 Kurami32 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2573

Summary by CodeRabbit

  • Bug Fixes
    • Share information now updates more reliably, keeping existing token and password status when those values aren’t provided in a new update.
    • Reduced unnecessary refreshes by only applying changes when the combined share information actually differs.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The setShareInfo mutation was modified to merge incoming shareInfo data with existing state rather than replacing it outright, preserving previously stored token and passwordValid values when those fields are omitted from the incoming payload.

Changes

Share Info Mutation Fix

Layer / File(s) Summary
Merge-based shareInfo update
frontend/src/store/mutations.js
setShareInfo merges incoming payload with existing state, preserves token and passwordValid when omitted, and skips redundant updates via JSON-stringified comparison before applying changes and triggering updateManifestLink()/emitStateChanged().

Estimated code review effort: 1 (Trivial) | ~5 minutes

Related issues: #2573 — addresses the missing token param issue when closing an image preview on a password-protected share by ensuring token is preserved rather than overwritten with undefined during state merges.

Poem

A rabbit hops through state so deep,
merging tokens it used to keep,
no more losing the secret key,
passwords stay safe as they should be,
hop, hop, hooray — bug's asleep! 🐇🔑

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: preserving the share token when returning from preview on password-protected shares.
Linked Issues check ✅ Passed The token-preservation merge directly addresses the reported missing-token 401 when closing preview on password-protected shared directories.
Out of Scope Changes check ✅ Passed The change appears narrowly scoped to shareInfo merging and token/password preservation, with no unrelated behavior added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/token-shares-with-pass

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
frontend/src/store/mutations.js (1)

1073-1080: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a shared merge helper to avoid future drift.

setShareInfo and setShareData now both implement a "merge-with-existing-state + JSON.stringify equality check" pattern independently, with setShareInfo additionally special-casing token/passwordValid. Extracting a shared mergeShareState(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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f85a89 and c3bfc69.

📒 Files selected for processing (1)
  • frontend/src/store/mutations.js

@gtsteffaniak gtsteffaniak merged commit 9936671 into dev/v1.5.1 Jul 2, 2026
22 checks passed
@Kurami32 Kurami32 deleted the fix/token-shares-with-pass branch July 2, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants