fix wallet filtering

This commit is contained in:
Riccardo Balbo 2024-10-15 15:13:04 +02:00 committed by k00b
parent 06afe2cda2
commit d30502a011
2 changed files with 22 additions and 9 deletions

View File

@ -181,13 +181,23 @@ const resolvers = {
throw new GqlAuthenticationError()
}
const filter = {
userId: me.id
}
if (includeReceivers && includeSenders) {
filter.OR = [
{ canReceive: true },
{ canSend: true }
]
} else if (includeReceivers) {
filter.canReceive = true
} else if (includeSenders) {
filter.canSend = true
}
return await models.wallet.findMany({
where: {
userId: me.id,
canReceive: includeReceivers,
canSend: includeSenders,
enabled: onlyEnabled !== undefined ? onlyEnabled : undefined
},
where: filter,
orderBy: {
priority: 'desc'
}

View File

@ -34,8 +34,8 @@ export function useWallet (name) {
// .filter(w => w.enabled && w.canSend)// filtered by the server
// .sort((a, b) => b.priority - a.priority) // already priority sorted by the server
.map(w => getWalletByType(w.type))
.filter(w => !w.isAvailable || w.isAvailable())[0]
name = bestWalletDef?.name
.filter(w => !w.isAvailable || w.isAvailable())
name = bestWalletDef?.[0]?.name
}
const walletDef = getWalletByName(name)
@ -113,7 +113,10 @@ export function useWallet (name) {
}, [deleteLogs])
const wallet = useMemo(() => {
if (!walletDef) return {}
if (!walletDef) {
console.log(name)
return {}
}
const wallet = {
...walletDef
}