Skip to content

Commit

Permalink
fix: the most stupid error of the century, return from the callback, …
Browse files Browse the repository at this point in the history
…applause, bow, curtains
  • Loading branch information
notbot00 committed Jan 29, 2023
1 parent 6613534 commit b2daca6
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions frontend/src/hooks/use-wallet-service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@ import { EventsOff, EventsOn } from '../wailsjs/runtime'

const logger = createLogger('DesktopWallet')

const debouncedResponseHandler = () => {
let lastTraceId: string | null = null
let lastEvent: string | null = null

return async (payload: InteractionResponse) => {
setTimeout(() => {
lastTraceId = null
lastEvent = null
}, 500)

if (lastTraceId === payload.traceID && lastEvent === payload.name) {
return
}

if ('data' in payload) {
await Handlers.RespondToInteraction(payload)
}
await Handlers.RespondToInteraction({ ...payload, data: {} })
}
}

export const useWalletService = (): Service => {
return {
TYPE: 'http',
Expand Down Expand Up @@ -92,8 +71,13 @@ export const useWalletService = (): Service => {
GetCurrentServiceInfo: Handlers.GetCurrentServiceInfo,

// API
EventsOn: EventsOn,
EventsOff: EventsOff,
RespondToInteraction: debouncedResponseHandler(),
EventsOn,
EventsOff,
RespondToInteraction: async (payload: any) => {
if ('data' in payload) {
return await Handlers.RespondToInteraction(payload)
}
return await Handlers.RespondToInteraction({ ...payload, data: {} })
}
}
}

0 comments on commit b2daca6

Please sign in to comment.