Merge branch 'master' into tordev
This commit is contained in:
commit
40ff3a83f4
@ -173,7 +173,7 @@ function tag (walletDef) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
||||||
const [logs, setLogs] = useState([])
|
const [logs, _setLogs] = useState([])
|
||||||
const [page, setPage] = useState(initialPage)
|
const [page, setPage] = useState(initialPage)
|
||||||
const [hasMore, setHasMore] = useState(true)
|
const [hasMore, setHasMore] = useState(true)
|
||||||
const [total, setTotal] = useState(0)
|
const [total, setTotal] = useState(0)
|
||||||
@ -183,6 +183,14 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
|||||||
const { getPage, error, notSupported } = useWalletLogDB()
|
const { getPage, error, notSupported } = useWalletLogDB()
|
||||||
const [getWalletLogs] = useLazyQuery(WALLET_LOGS, SSR ? {} : { fetchPolicy: 'cache-and-network' })
|
const [getWalletLogs] = useLazyQuery(WALLET_LOGS, SSR ? {} : { fetchPolicy: 'cache-and-network' })
|
||||||
|
|
||||||
|
const setLogs = useCallback((action) => {
|
||||||
|
_setLogs(action)
|
||||||
|
// action can be a React state dispatch function
|
||||||
|
const newLogs = typeof action === 'function' ? action(logs) : action
|
||||||
|
// make sure 'more' button is removed if logs were deleted
|
||||||
|
if (newLogs.length === 0) setHasMore(false)
|
||||||
|
}, [logs, _setLogs, setHasMore])
|
||||||
|
|
||||||
const loadLogsPage = useCallback(async (page, pageSize, walletDef) => {
|
const loadLogsPage = useCallback(async (page, pageSize, walletDef) => {
|
||||||
try {
|
try {
|
||||||
let result = { data: [], hasMore: false }
|
let result = { data: [], hasMore: false }
|
||||||
@ -193,14 +201,14 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
|
|||||||
const query = walletDef ? window.IDBKeyRange.bound([tag(walletDef), -Infinity], [tag(walletDef), Infinity]) : null
|
const query = walletDef ? window.IDBKeyRange.bound([tag(walletDef), -Infinity], [tag(walletDef), Infinity]) : null
|
||||||
|
|
||||||
result = await getPage(page, pageSize, indexName, query, 'prev')
|
result = await getPage(page, pageSize, indexName, query, 'prev')
|
||||||
// no walletType means we're using the local IDB
|
// if given wallet has no walletType it means logs are only stored in local IDB
|
||||||
if (!walletDef?.walletType) {
|
if (walletDef && !walletDef.walletType) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const { data } = await getWalletLogs({
|
const { data } = await getWalletLogs({
|
||||||
variables: {
|
variables: {
|
||||||
type: walletDef.walletType,
|
type: walletDef?.walletType,
|
||||||
// if it client logs has more, page based on it's range
|
// if it client logs has more, page based on it's range
|
||||||
from: result?.data[result.data.length - 1]?.ts && result.hasMore ? String(result.data[result.data.length - 1].ts) : null,
|
from: result?.data[result.data.length - 1]?.ts && result.hasMore ? String(result.data[result.data.length - 1].ts) : null,
|
||||||
// if we have a cursor (this isn't the first page), page based on it's range
|
// if we have a cursor (this isn't the first page), page based on it's range
|
||||||
|
@ -20,11 +20,10 @@ export default function Wallet ({ ssrData }) {
|
|||||||
const reorder = useCallback(async (sourceIndex, targetIndex) => {
|
const reorder = useCallback(async (sourceIndex, targetIndex) => {
|
||||||
const newOrder = [...wallets.filter(w => w.config?.enabled)]
|
const newOrder = [...wallets.filter(w => w.config?.enabled)]
|
||||||
const [source] = newOrder.splice(sourceIndex, 1)
|
const [source] = newOrder.splice(sourceIndex, 1)
|
||||||
const newTargetIndex = sourceIndex < targetIndex ? targetIndex - 1 : targetIndex
|
|
||||||
|
|
||||||
const priorities = newOrder.slice(0, newTargetIndex)
|
const priorities = newOrder.slice(0, targetIndex)
|
||||||
.concat(source)
|
.concat(source)
|
||||||
.concat(newOrder.slice(newTargetIndex))
|
.concat(newOrder.slice(targetIndex))
|
||||||
.map((w, i) => ({ wallet: w, priority: i }))
|
.map((w, i) => ({ wallet: w, priority: i }))
|
||||||
|
|
||||||
await setPriorities(priorities)
|
await setPriorities(priorities)
|
||||||
|
@ -16,7 +16,7 @@ export const fields = [
|
|||||||
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' }),
|
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' }),
|
||||||
help: `you can get an API key from [Blink Dashboard](${galoyBlinkDashboardUrl}).\nPlease make sure to select ONLY the 'Read' and 'Write' scopes when generating this API key.`,
|
help: `you can get an API key from [Blink Dashboard](${galoyBlinkDashboardUrl}).\nPlease make sure to select ONLY the 'Read' and 'Write' scopes when generating this API key.`,
|
||||||
optional: 'for sending',
|
optional: 'for sending',
|
||||||
requiredWithout: ['apiKeyRecv']
|
requiredWithout: 'apiKeyRecv'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'currency',
|
name: 'currency',
|
||||||
@ -40,7 +40,7 @@ export const fields = [
|
|||||||
placeholder: 'blink_...',
|
placeholder: 'blink_...',
|
||||||
optional: 'for receiving',
|
optional: 'for receiving',
|
||||||
serverOnly: true,
|
serverOnly: true,
|
||||||
requiredWithout: ['apiKey'],
|
requiredWithout: 'apiKey',
|
||||||
validate: string()
|
validate: string()
|
||||||
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' })
|
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' })
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user