fix: sharePws in localStorage persistieren (PW-Button bleibt nach Reload)
This commit is contained in:
@@ -74,7 +74,9 @@ function PublicShareModal({ item, itemType, onClose, onShareCreated, toast }) {
|
|||||||
setNewLink(link);
|
setNewLink(link);
|
||||||
setNewPw(password.trim());
|
setNewPw(password.trim());
|
||||||
setShares(p => [d.share, ...p]);
|
setShares(p => [d.share, ...p]);
|
||||||
onShareCreated?.(d.token, password.trim());
|
if (onShareCreated) {
|
||||||
|
onShareCreated(d.token, password.trim());
|
||||||
|
}
|
||||||
navigator.clipboard?.writeText(link).catch(()=>{});
|
navigator.clipboard?.writeText(link).catch(()=>{});
|
||||||
toast('Link erstellt & kopiert ✓');
|
toast('Link erstellt & kopiert ✓');
|
||||||
setPassword(genPw());
|
setPassword(genPw());
|
||||||
@@ -595,7 +597,9 @@ export default function Dateien({ toast, mobile }) {
|
|||||||
const [publicShareItem, setPublicShareItem] = useState(null);
|
const [publicShareItem, setPublicShareItem] = useState(null);
|
||||||
const [publicShares, setPublicShares] = useState([]);
|
const [publicShares, setPublicShares] = useState([]);
|
||||||
const [showPublicLinks, setShowPublicLinks] = useState(false);
|
const [showPublicLinks, setShowPublicLinks] = useState(false);
|
||||||
const [sharePws, setSharePws] = useState({}); // {token: plaintext_pw}
|
const [sharePws, setSharePws] = useState(() => {
|
||||||
|
try { return JSON.parse(localStorage.getItem('dicken_share_pws') || '{}'); } catch { return {}; }
|
||||||
|
});
|
||||||
const [pwPrompt, setPwPrompt] = useState(null); // {file}
|
const [pwPrompt, setPwPrompt] = useState(null); // {file}
|
||||||
const [uploading, setUploading] = useState(false);
|
const [uploading, setUploading] = useState(false);
|
||||||
const [dragOver, setDragOver] = useState(false);
|
const [dragOver, setDragOver] = useState(false);
|
||||||
@@ -734,7 +738,13 @@ export default function Dateien({ toast, mobile }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{shareItem && <ShareModal item={shareItem.item} type={shareItem.type} onClose={()=>{setShareItem(null);load();}} toast={toast}/>}
|
{shareItem && <ShareModal item={shareItem.item} type={shareItem.type} onClose={()=>{setShareItem(null);load();}} toast={toast}/>}
|
||||||
{publicShareItem && <PublicShareModal item={publicShareItem.item} itemType={publicShareItem.type} onClose={()=>{setPublicShareItem(null);api('/tools/dateien/public-shares').then(d=>setPublicShares(d.shares||[])).catch(()=>{});}} onShareCreated={(token,pw)=>setSharePws(p=>({...p,[token]:pw}))} toast={toast}/>}
|
{publicShareItem && <PublicShareModal item={publicShareItem.item} itemType={publicShareItem.type} onClose={()=>{setPublicShareItem(null);api('/tools/dateien/public-shares').then(d=>setPublicShares(d.shares||[])).catch(()=>{});}} onShareCreated={(token,pw)=>{
|
||||||
|
setSharePws(p=>{
|
||||||
|
const next={...p,[token]:pw};
|
||||||
|
try{localStorage.setItem('dicken_share_pws',JSON.stringify(next));}catch{}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}} toast={toast}/>}
|
||||||
|
|
||||||
{/* ── Aktive öffentliche Links ──────────────────────────────────────── */}
|
{/* ── Aktive öffentliche Links ──────────────────────────────────────── */}
|
||||||
{publicShares.length > 0 && tab === 'own' && (
|
{publicShares.length > 0 && tab === 'own' && (
|
||||||
|
|||||||
Reference in New Issue
Block a user