Display WS state in favicon

This commit is contained in:
2025-12-01 08:44:30 +01:00
parent 64985bb39e
commit 7acb0cbafa
3 changed files with 39 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import Favicon from "react-favicon";
import { WSState } from "./MatrixWS";
// Taken from https://github.com/element-hq/element-web/blob/0577e245dac944bd85eea07b93a9762a93062f62/src/favicon.ts
function getInitialFavicon(): HTMLLinkElement[] {
@@ -21,6 +22,14 @@ let iconPath = getInitialFavicon()[0].getAttribute("href")!;
export function AppIconModifier(p: {
numberUnread: number;
state: string;
}): React.ReactElement {
return <Favicon url={iconPath} alertCount={p.numberUnread} />;
const isError = p.state === WSState.Error || p.state === WSState.Closed;
return (
<Favicon
url={iconPath}
alertFillColor={isError ? "orange" : undefined}
alertCount={isError ? "x" : p.numberUnread}
/>
);
}