fix wallet filtering
This commit is contained in:
parent
06afe2cda2
commit
d30502a011
|
@ -181,13 +181,23 @@ const resolvers = {
|
||||||
throw new GqlAuthenticationError()
|
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({
|
return await models.wallet.findMany({
|
||||||
where: {
|
where: filter,
|
||||||
userId: me.id,
|
|
||||||
canReceive: includeReceivers,
|
|
||||||
canSend: includeSenders,
|
|
||||||
enabled: onlyEnabled !== undefined ? onlyEnabled : undefined
|
|
||||||
},
|
|
||||||
orderBy: {
|
orderBy: {
|
||||||
priority: 'desc'
|
priority: 'desc'
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ export function useWallet (name) {
|
||||||
// .filter(w => w.enabled && w.canSend)// filtered by the server
|
// .filter(w => w.enabled && w.canSend)// filtered by the server
|
||||||
// .sort((a, b) => b.priority - a.priority) // already priority sorted by the server
|
// .sort((a, b) => b.priority - a.priority) // already priority sorted by the server
|
||||||
.map(w => getWalletByType(w.type))
|
.map(w => getWalletByType(w.type))
|
||||||
.filter(w => !w.isAvailable || w.isAvailable())[0]
|
.filter(w => !w.isAvailable || w.isAvailable())
|
||||||
name = bestWalletDef?.name
|
name = bestWalletDef?.[0]?.name
|
||||||
}
|
}
|
||||||
|
|
||||||
const walletDef = getWalletByName(name)
|
const walletDef = getWalletByName(name)
|
||||||
|
@ -113,7 +113,10 @@ export function useWallet (name) {
|
||||||
}, [deleteLogs])
|
}, [deleteLogs])
|
||||||
|
|
||||||
const wallet = useMemo(() => {
|
const wallet = useMemo(() => {
|
||||||
if (!walletDef) return {}
|
if (!walletDef) {
|
||||||
|
console.log(name)
|
||||||
|
return {}
|
||||||
|
}
|
||||||
const wallet = {
|
const wallet = {
|
||||||
...walletDef
|
...walletDef
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue