Implement custom throttle function for performance
This commit is contained in:
@@ -31,9 +31,10 @@
|
||||
"typescript": "~5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@welshman/lib": "~0.0.28",
|
||||
"@welshman/feeds": "~0.0.26",
|
||||
"@types/throttle-debounce": "^5.0.2",
|
||||
"@welshman/dvm": "~0.0.10",
|
||||
"@welshman/feeds": "~0.0.26",
|
||||
"@welshman/lib": "~0.0.28",
|
||||
"@welshman/net": "~0.0.40",
|
||||
"@welshman/signer": "~0.0.16",
|
||||
"@welshman/store": "~0.0.12",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {throttle} from 'throttle-debounce'
|
||||
import {throttle} from '@welshman/lib'
|
||||
import {Repository, Relay} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Tracker} from "@welshman/net"
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import {openDB, deleteDB} from "idb"
|
||||
import type {IDBPDatabase} from "idb"
|
||||
import {throttle} from "throttle-debounce"
|
||||
import {writable} from "svelte/store"
|
||||
import type {Unsubscriber, Writable} from "svelte/store"
|
||||
import {indexBy, fromPairs} from "@welshman/lib"
|
||||
import {indexBy, throttle, fromPairs} from "@welshman/lib"
|
||||
import type {TrustedEvent, Repository} from "@welshman/util"
|
||||
import type {Tracker} from "@welshman/net"
|
||||
import {withGetter, adapter, throttled, custom} from "@welshman/store"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {throttle} from 'throttle-debounce'
|
||||
import {inc} from '@welshman/lib'
|
||||
import {inc, throttle} from '@welshman/lib'
|
||||
import {custom} from '@welshman/store'
|
||||
import {repository} from './core'
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {throttle} from 'throttle-debounce'
|
||||
import {derived, writable} from 'svelte/store'
|
||||
import {max, addToMapKey, inc, dec} from '@welshman/lib'
|
||||
import {max, throttle, addToMapKey, inc, dec} from '@welshman/lib'
|
||||
import {getListTags, getPubkeyTagValues} from '@welshman/util'
|
||||
import {throttled, withGetter} from '@welshman/store'
|
||||
import {pubkey} from './session'
|
||||
|
||||
Reference in New Issue
Block a user