fix wallet filtering
This commit is contained in:
parent
06afe2cda2
commit
d30502a011
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue