diff options
author | Sebastian <sebasjm@gmail.com> | 2024-01-11 16:41:24 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-01-11 16:41:42 -0300 |
commit | 82d4ed90caa4a6ea3bdda1fb80ccecf3dc3637f9 (patch) | |
tree | 59162f0565311e8699ca643a8bd60337ee7f582b /packages/web-util | |
parent | ca67640f9f94f1150c0fb67c148dc79daa9d3fa0 (diff) | |
download | wallet-core-82d4ed90caa4a6ea3bdda1fb80ccecf3dc3637f9.tar.xz |
2fa
Diffstat (limited to 'packages/web-util')
-rw-r--r-- | packages/web-util/src/components/LocalNotificationBanner.tsx | 18 | ||||
-rw-r--r-- | packages/web-util/src/utils/http-impl.browser.ts | 11 | ||||
-rw-r--r-- | packages/web-util/src/utils/http-impl.sw.ts | 13 |
3 files changed, 19 insertions, 23 deletions
diff --git a/packages/web-util/src/components/LocalNotificationBanner.tsx b/packages/web-util/src/components/LocalNotificationBanner.tsx index ab46703cb..62733ab3c 100644 --- a/packages/web-util/src/components/LocalNotificationBanner.tsx +++ b/packages/web-util/src/components/LocalNotificationBanner.tsx @@ -1,9 +1,8 @@ import { h, Fragment, VNode } from "preact"; import { Attention } from "./Attention.js"; import { Notification } from "../index.browser.js"; -// import { useSettings } from "../hooks/settings.js"; -export function LocalNotificationBanner({ notification }: { notification?: Notification }): VNode { +export function LocalNotificationBanner({ notification, showDebug }: { notification?: Notification, showDebug?: boolean }): VNode { if (!notification) return <Fragment /> switch (notification.message.type) { case "error": @@ -17,7 +16,9 @@ export function LocalNotificationBanner({ notification }: { notification?: Notif {notification.message.description} </div> } - {/* <MaybeShowDebugInfo info={notification.message.debug} /> */} + {showDebug && <pre class="whitespace-break-spaces "> + {notification.message.debug} + </pre>} </Attention> </div> </div> @@ -30,14 +31,3 @@ export function LocalNotificationBanner({ notification }: { notification?: Notif } } - -// function MaybeShowDebugInfo({ info }: { info: any }): VNode { -// const [settings] = useSettings() -// if (settings.showDebugInfo) { -// return <pre class="whitespace-break-spaces "> -// {info} -// </pre> -// } -// return <Fragment /> -// } - diff --git a/packages/web-util/src/utils/http-impl.browser.ts b/packages/web-util/src/utils/http-impl.browser.ts index 974a7d1b8..18140ef13 100644 --- a/packages/web-util/src/utils/http-impl.browser.ts +++ b/packages/web-util/src/utils/http-impl.browser.ts @@ -73,10 +73,13 @@ export class BrowserHttpLib implements HttpRequestLibrary { ? encodeBody(requestBody) : undefined; - const requestHeadersMap = { - ...getDefaultHeaders(requestMethod), - ...requestHeader, - }; + const requestHeadersMap = getDefaultHeaders(requestMethod); + if (requestHeader) { + Object.entries(requestHeader).forEach(([key, value]) => { + if (value === undefined) return; + requestHeadersMap[key] = value + }) + } return new Promise<HttpResponse>((resolve, reject) => { const myRequest = new XMLHttpRequest(); diff --git a/packages/web-util/src/utils/http-impl.sw.ts b/packages/web-util/src/utils/http-impl.sw.ts index 3120309f4..3c269e695 100644 --- a/packages/web-util/src/utils/http-impl.sw.ts +++ b/packages/web-util/src/utils/http-impl.sw.ts @@ -68,10 +68,13 @@ export class ServiceWorkerHttpLib implements HttpRequestLibrary { let myBody: ArrayBuffer | undefined = requestMethod === "POST" ? encodeBody(requestBody) : undefined; - const requestHeadersMap = { - ...getDefaultHeaders(requestMethod), - ...requestHeader, - }; + const requestHeadersMap = getDefaultHeaders(requestMethod); + if (requestHeader) { + Object.entries(requestHeader).forEach(([key, value]) => { + if (value === undefined) return; + requestHeadersMap[key] = value + }) + } const controller = new AbortController(); let timeoutId: any | undefined; @@ -190,7 +193,7 @@ function makeJsonHandler( requestMethod, httpStatusCode: response.status, }, - message, + message, ); } } |