From cebe5374fd2eb5ad24ccb083368a1d8232edd094 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 23 Dec 2024 13:30:20 +0200 Subject: [PATCH] web/preferences: add option to change favicon --- web/index.html | 2 +- web/src/api/types/preferences/preferences.ts | 6 ++++++ web/src/ui/StylePreferences.tsx | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/web/index.html b/web/index.html index 5de864d..40252d6 100644 --- a/web/index.html +++ b/web/index.html @@ -2,7 +2,7 @@ - + gomuks web diff --git a/web/src/api/types/preferences/preferences.ts b/web/src/api/types/preferences/preferences.ts index 9f7e253..94e8764 100644 --- a/web/src/api/types/preferences/preferences.ts +++ b/web/src/api/types/preferences/preferences.ts @@ -183,6 +183,12 @@ export const preferences = { allowedContexts: anyGlobalContext, defaultValue: "gomuks web", }), + favicon: new Preference({ + displayName: "Favicon", + description: "The URL to use for the favicon.", + allowedContexts: anyContext, + defaultValue: "gomuks.png", + }), } as const export const existingPreferenceKeys = new Set(Object.keys(preferences)) diff --git a/web/src/ui/StylePreferences.tsx b/web/src/ui/StylePreferences.tsx index b410598..8c2da2b 100644 --- a/web/src/ui/StylePreferences.tsx +++ b/web/src/ui/StylePreferences.tsx @@ -13,7 +13,7 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -import React, { useInsertionEffect } from "react" +import React, { useEffect, useInsertionEffect } from "react" import type Client from "@/api/client.ts" import { RoomStateStore, usePreferences } from "@/api/statestore" @@ -128,7 +128,12 @@ const StylePreferences = ({ client, activeRoom }: StylePreferencesProps) => { @import url("_gomuks/codeblock/${preferences.code_block_theme}.css"); `, [preferences.code_block_theme], "gomuks-pref-code-block-theme") useAsyncStyle(() => preferences.custom_css, [preferences.custom_css], "gomuks-pref-custom-css") + useEffect(() => { + favicon.href = preferences.favicon + }, [preferences.favicon]) return null } +const favicon = document.getElementById("favicon") as HTMLLinkElement + export default React.memo(StylePreferences)