Skip to content

Commit

Permalink
Merge branch 'master' into tordev
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn authored Nov 5, 2024
2 parents 571a230 + 803daed commit 40ff3a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
16 changes: 12 additions & 4 deletions components/wallet-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function tag (walletDef) {
}

export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
const [logs, setLogs] = useState([])
const [logs, _setLogs] = useState([])
const [page, setPage] = useState(initialPage)
const [hasMore, setHasMore] = useState(true)
const [total, setTotal] = useState(0)
Expand All @@ -183,6 +183,14 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
const { getPage, error, notSupported } = useWalletLogDB()
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) => {
try {
let result = { data: [], hasMore: false }
Expand All @@ -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

result = await getPage(page, pageSize, indexName, query, 'prev')
// no walletType means we're using the local IDB
if (!walletDef?.walletType) {
// if given wallet has no walletType it means logs are only stored in local IDB
if (walletDef && !walletDef.walletType) {
return result
}
}
const { data } = await getWalletLogs({
variables: {
type: walletDef.walletType,
type: walletDef?.walletType,
// 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,
// if we have a cursor (this isn't the first page), page based on it's range
Expand Down
5 changes: 2 additions & 3 deletions pages/settings/wallets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ export default function Wallet ({ ssrData }) {
const reorder = useCallback(async (sourceIndex, targetIndex) => {
const newOrder = [...wallets.filter(w => w.config?.enabled)]
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(newOrder.slice(newTargetIndex))
.concat(newOrder.slice(targetIndex))
.map((w, i) => ({ wallet: w, priority: i }))

await setPriorities(priorities)
Expand Down
4 changes: 2 additions & 2 deletions wallets/blink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const fields = [
.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.`,
optional: 'for sending',
requiredWithout: ['apiKeyRecv']
requiredWithout: 'apiKeyRecv'
},
{
name: 'currency',
Expand All @@ -40,7 +40,7 @@ export const fields = [
placeholder: 'blink_...',
optional: 'for receiving',
serverOnly: true,
requiredWithout: ['apiKey'],
requiredWithout: 'apiKey',
validate: string()
.matches(/^blink_[A-Za-z0-9]+$/, { message: 'must match pattern blink_A-Za-z0-9' })
},
Expand Down

0 comments on commit 40ff3a8

Please sign in to comment.