From 7b3af774494c31f8fcd829d20f9bb5f46242320a Mon Sep 17 00:00:00 2001 From: whoswhip Date: Tue, 20 Jan 2026 09:14:48 -0500 Subject: [PATCH] feat: enhance decryption process with status updates and improved user feedback --- .../src/routes/[id]/+page.svelte | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/SharpbinV3.Client/src/routes/[id]/+page.svelte b/SharpbinV3.Client/src/routes/[id]/+page.svelte index 1bbf751..bf2be71 100644 --- a/SharpbinV3.Client/src/routes/[id]/+page.svelte +++ b/SharpbinV3.Client/src/routes/[id]/+page.svelte @@ -52,6 +52,7 @@ let pasteContent = ''; let decryptedContent: string | null = null; let decryptError = ''; + let decryptStatus = ''; let contentRendered = false; let downloadedPaste = false; let copiedPaste = false; @@ -132,6 +133,7 @@ isBinary = isBinaryData(buffer); if (isBinary) { contentRendered = true; + decryptStatus = ''; return; } @@ -159,6 +161,7 @@ const wrapped = `
${highlighted}
`; pasteContent = addLineNumbers(wrapped); contentRendered = true; + decryptStatus = ''; } async function updatePaste(content: string | null, metadata: Paste | null) { @@ -278,39 +281,53 @@ try { if (data?.paste && data.paste.visibility === 2) { contentRendered = false; + decryptStatus = 'Preparing decryption...'; const urlHash = window.location.hash.slice(1); if (urlHash) { const passwordFromUrl = atob(urlHash); + decryptStatus = 'Deriving key...'; decryptedContent = await decryptAES(data.content, passwordFromUrl); if (decryptedContent === null) { + decryptStatus = 'Waiting for password...'; const password = await promptUser('decrypt'); if (password) { + decryptStatus = 'Deriving key...'; decryptedContent = await decryptAES(data.content, password); if (decryptedContent === null) { decryptError = 'Incorrect password. Please try again.'; + decryptStatus = 'Decryption failed.'; } else { renderCode(); history.replaceState(null, '', window.location.pathname + window.location.search); } + } else { + decryptStatus = 'Decryption canceled.'; } } else { renderCode(); } return; } + decryptStatus = 'Waiting for password...'; const password = await promptUser('decrypt'); if (password) { + decryptStatus = 'Deriving key...'; decryptedContent = await decryptAES(data.content, password); if (decryptedContent === null) { decryptError = 'Incorrect password. Please try again.'; + decryptStatus = 'Decryption failed.'; } else { renderCode(); } + } else { + decryptStatus = 'Decryption canceled.'; } } else { + decryptStatus = 'Rendering content...'; renderCode(); } } catch { + decryptStatus = 'Rendering content...'; renderCode(); } }); @@ -359,9 +376,9 @@
-
+
{#if data.paste}

+ > + {decryptStatus || 'Loading...'} +