stacker.news/wallets/client/hooks/diagnostics.js
ekzyis 243b094fcd
Wallet debug logs (#2307)
* Add wallet debug logs

* Add checkbox to toggle diagnostics

* Require authentication for /wallets/debug

* Update debug log messages

* Use me.privates.diagnostics as source of truth
2025-07-23 10:42:14 -05:00

24 lines
754 B
JavaScript

import { useMe } from '@/components/me'
import { useToast } from '@/components/toast'
import { SET_DIAGNOSTICS } from '@/fragments/users'
import { useMutation } from '@apollo/client'
import { useCallback } from 'react'
export function useDiagnostics () {
const { me, refreshMe } = useMe()
const [mutate] = useMutation(SET_DIAGNOSTICS)
const toaster = useToast()
const setDiagnostics = useCallback(async (diagnostics) => {
try {
await mutate({ variables: { diagnostics } })
await refreshMe()
} catch (err) {
console.error('failed to toggle diagnostics:', err)
toaster.danger('failed to toggle diagnostics')
}
}, [mutate, toaster, refreshMe])
return [me?.privates?.diagnostics ?? false, setDiagnostics]
}