diff --git a/web/src/common/ws.ts b/web/src/common/ws.ts index f7c3ee063..bbcb978a3 100644 --- a/web/src/common/ws.ts +++ b/web/src/common/ws.ts @@ -33,10 +33,13 @@ export class WebsocketClient { this.messageSocket.addEventListener("close", (e) => { console.debug(`authentik/ws: closed ws connection: ${e}`); if (this.retryDelay > 3000) { - showMessage({ - level: MessageLevel.error, - message: t`Connection error, reconnecting...`, - }); + showMessage( + { + level: MessageLevel.error, + message: t`Connection error, reconnecting...`, + }, + true, + ); } setTimeout(() => { console.debug(`authentik/ws: reconnecting ws in ${this.retryDelay}ms`); diff --git a/web/src/elements/messages/MessageContainer.ts b/web/src/elements/messages/MessageContainer.ts index ac516d283..be2f3e491 100644 --- a/web/src/elements/messages/MessageContainer.ts +++ b/web/src/elements/messages/MessageContainer.ts @@ -9,12 +9,12 @@ import { EVENT_WS_MESSAGE, WS_MSG_TYPE_MESSAGE } from "../../constants"; import "./Message"; import { APIMessage } from "./Message"; -export function showMessage(message: APIMessage): void { +export function showMessage(message: APIMessage, unique = false): void { const container = document.querySelector("ak-message-container"); if (!container) { throw new Error("failed to find message container"); } - container.addMessage(message); + container.addMessage(message, unique); container.requestUpdate(); } @@ -44,7 +44,13 @@ export class MessageContainer extends LitElement { }) as EventListener); } - addMessage(message: APIMessage): void { + addMessage(message: APIMessage, unique = false): void { + if (unique) { + const matchingMessages = this.messages.filter((m) => m.message == message.message); + if (matchingMessages.length > 0) { + return; + } + } this.messages.push(message); }