mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: tsc error
This commit is contained in:
@@ -97,15 +97,21 @@ export const addTransactionCapability = (
|
|||||||
* prefetches some data and stores in memory,
|
* prefetches some data and stores in memory,
|
||||||
* useful if these data points will be used together often
|
* useful if these data points will be used together often
|
||||||
* */
|
* */
|
||||||
const prefetch = async(type: keyof SignalDataTypeMap, ids: string[]) => {
|
const prefetch = async<T extends keyof SignalDataTypeMap>(type: T, ids: string[]) => {
|
||||||
const dict = transactionCache[type]
|
const dict = transactionCache[type]
|
||||||
const idsRequiringFetch = dict ? ids.filter(item => !(item in dict)) : ids
|
const idsRequiringFetch = dict
|
||||||
|
? ids.filter(item => typeof dict[item] !== 'undefined')
|
||||||
|
: ids
|
||||||
// only fetch if there are any items to fetch
|
// only fetch if there are any items to fetch
|
||||||
if(idsRequiringFetch.length) {
|
if(idsRequiringFetch.length) {
|
||||||
dbQueriesInTransaction += 1
|
dbQueriesInTransaction += 1
|
||||||
const result = await state.get(type, idsRequiringFetch)
|
const result = await state.get(type, idsRequiringFetch)
|
||||||
|
|
||||||
transactionCache[type] = Object.assign(transactionCache[type] || { }, result)
|
transactionCache[type] ||= {}
|
||||||
|
transactionCache[type] = Object.assign(
|
||||||
|
transactionCache[type]!,
|
||||||
|
result
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user