From 82d4ed90caa4a6ea3bdda1fb80ccecf3dc3637f9 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 11 Jan 2024 16:41:24 -0300 Subject: 2fa --- .../src/components/LocalNotificationBanner.tsx | 18 ++++-------------- packages/web-util/src/utils/http-impl.browser.ts | 11 +++++++---- packages/web-util/src/utils/http-impl.sw.ts | 13 ++++++++----- 3 files changed, 19 insertions(+), 23 deletions(-) (limited to 'packages/web-util/src') 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 switch (notification.message.type) { case "error": @@ -17,7 +16,9 @@ export function LocalNotificationBanner({ notification }: { notification?: Notif {notification.message.description} } - {/* */} + {showDebug &&
+              {notification.message.debug}
+            
} @@ -30,14 +31,3 @@ export function LocalNotificationBanner({ notification }: { notification?: Notif } } - -// function MaybeShowDebugInfo({ info }: { info: any }): VNode { -// const [settings] = useSettings() -// if (settings.showDebugInfo) { -// return
-//       {info}
-//     
-// } -// return -// } - 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((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, ); } } -- cgit v1.2.3