Implement custom throttle function for performance

This commit is contained in:
Jon Staab
2024-12-11 16:41:31 -08:00
parent ab0517e804
commit 0fcb2482d8
12 changed files with 68 additions and 34 deletions
+16 -12
View File
@@ -14,22 +14,26 @@ export const setPlaintext = (e: TrustedEvent, content: string) =>
export const ensurePlaintext = async (e: TrustedEvent) => {
if (e.content && !getPlaintext(e)) {
const $signer = getSigner(getSession(e.pubkey))
const $session = getSession(e.pubkey)
if ($signer) {
let result
if (!$session) return
try {
result = await decrypt($signer, e.pubkey, e.content)
} catch (e: any) {
if (!String(e).match(/invalid base64/)) {
throw e
}
const $signer = getSigner($session)
if (!$signer) return
let result
try {
result = await decrypt($signer, e.pubkey, e.content)
} catch (e: any) {
if (!String(e).match(/invalid base64/)) {
throw e
}
}
if (result) {
setPlaintext(e, result)
}
if (result) {
setPlaintext(e, result)
}
}