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);
|
||||
setNewPw(password.trim());
|
||||
setShares(p => [d.share, ...p]);
|
||||
onShareCreated?.(d.token, password.trim());
|
||||
if (onShareCreated) {
|
||||
onShareCreated(d.token, password.trim());
|
||||
}
|
||||
navigator.clipboard?.writeText(link).catch(()=>{});
|
||||
toast('Link erstellt & kopiert ✓');
|
||||
setPassword(genPw());
|
||||
@@ -595,7 +597,9 @@ export default function Dateien({ toast, mobile }) {
|
||||
const [publicShareItem, setPublicShareItem] = useState(null);
|
||||
const [publicShares, setPublicShares] = useState([]);
|
||||
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 [uploading, setUploading] = useState(false);
|
||||
const [dragOver, setDragOver] = useState(false);
|
||||
@@ -734,7 +738,13 @@ export default function Dateien({ toast, mobile }) {
|
||||
</div>
|
||||
)}
|
||||
{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 ──────────────────────────────────────── */}
|
||||
{publicShares.length > 0 && tab === 'own' && (
|
||||
|
||||
Reference in New Issue
Block a user