diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/backend.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/backend.ts | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/backend.ts b/packages/merchant-backoffice-ui/src/hooks/backend.ts index eaeede103..4515f0557 100644 --- a/packages/merchant-backoffice-ui/src/hooks/backend.ts +++ b/packages/merchant-backoffice-ui/src/hooks/backend.ts @@ -91,7 +91,7 @@ const CHECK_CONFIG_INTERVAL_OK = 5 * 60 * 1000; const CHECK_CONFIG_INTERVAL_FAIL = 2 * 1000; export function useBackendConfig(): HttpResponse< - MerchantBackend.VersionResponse, + MerchantBackend.VersionResponse | undefined, RequestError<MerchantBackend.ErrorDetail> > { const { request } = useBackendBaseRequest(); @@ -340,6 +340,14 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { if (refunded !== undefined) params.refunded = refunded; if (wired !== undefined) params.wired = wired; if (date_s !== undefined) params.date_s = date_s; + if (delta === 0) { + //in this case we can already assume the response + //and avoid network + return Promise.resolve({ + ok: true, + data: {orders:[]} as T, + }) + } return requestHandler<T>(baseUrl, endpoint, { params, token }); }, [baseUrl, token], @@ -385,6 +393,14 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { const params: any = {}; if (payto_uri !== undefined) params.payto_uri = payto_uri; if (verified !== undefined) params.verified = verified; + if (delta === 0) { + //in this case we can already assume the response + //and avoid network + return Promise.resolve({ + ok: true, + data: {transfers:[]} as T, + }) + } if (delta !== undefined) { params.limit = delta; } @@ -403,6 +419,14 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { ): Promise<HttpResponseOk<T>> { const [endpoint, position, delta] = args const params: any = {}; + if (delta === 0) { + //in this case we can already assume the response + //and avoid network + return Promise.resolve({ + ok: true, + data: {templates:[]} as T, + }) + } if (delta !== undefined) { params.limit = delta; } @@ -421,6 +445,14 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { ): Promise<HttpResponseOk<T>> { const [endpoint, position, delta] = args const params: any = {}; + if (delta === 0) { + //in this case we can already assume the response + //and avoid network + return Promise.resolve({ + ok: true, + data: {webhooks:[]} as T, + }) + } if (delta !== undefined) { params.limit = delta; } |