05/29 Fixed a shared item isn't auto updated when it's modified by owner

This commit is contained in:
2026-05-29 14:58:11 -04:00
parent 5f8ce4b5de
commit 977805f5e7
3 changed files with 44 additions and 10 deletions
+20 -8
View File
@@ -2212,8 +2212,20 @@ const Vault = (() => {
return;
}
try {
// Always fetch fresh share data from the server so the grantee sees
// the owner's latest version, not the ciphertext that was baked into
// the button's data-* attributes when the tab was last rendered.
const shareId = parseInt(btn.dataset.viewShare);
const inboxRes = await apiFetch("/api/sharing/inbox");
if (!inboxRes) return;
const inbox = await inboxRes.json();
const freshShare = inbox.find((s) => s.id === shareId);
if (!freshShare || !freshShare.owner_public_key) {
showToast("Share not found or owner key unavailable.", "error");
return;
}
const ownerPubKey = await SharingCrypto.importPublicKey(
btn.dataset.ownerKey,
freshShare.owner_public_key,
);
const sharedKey = await SharingCrypto.deriveSharedKey(
SharingSession.getKey(),
@@ -2221,21 +2233,21 @@ const Vault = (() => {
);
const plain = await SharingCrypto.decryptShare(
sharedKey,
btn.dataset.enc,
btn.dataset.iv,
freshShare.enc_data,
freshShare.iv,
);
// Decrypt the item name if an encrypted version is available.
// Falls back to the non-sensitive label for legacy shares.
let displayName = btn.dataset.name;
if (btn.dataset.encName && btn.dataset.ivName) {
let displayName = freshShare.item_name;
if (freshShare.enc_name && freshShare.iv_name) {
const decrypted = await SharingCrypto.decryptName(
sharedKey,
btn.dataset.encName,
btn.dataset.ivName,
freshShare.enc_name,
freshShare.iv_name,
);
if (decrypted) displayName = decrypted;
}
showSharedItemDetails(displayName, btn.dataset.type, plain);
showSharedItemDetails(displayName, freshShare.item_type, plain);
} catch (err) {
showToast("Could not decrypt: " + err.message, "error");
}