Client: Replaced get favicon to new handler

This commit is contained in:
Alexey Safronov 2024-03-27 12:31:25 +04:00
parent 8031b1a749
commit fbbfd019db
4 changed files with 7 additions and 48 deletions

View File

@ -14,17 +14,16 @@
--> -->
<link <link
id="favicon" id="favicon"
rel="shortcut icon" rel="icon"
sizes="any" type="image/x-icon"
href="/storage/whitelabel/root/favicon.png" href="/logo.ashx?logotype=3"
onerror="this.onerror=null;this.href='favicon.ico';"
/> />
<link <!-- <link
id="favicon-icon" id="favicon-icon"
rel="icon" rel="icon"
href="/storage/whitelabel/root/favicon.png" href="/storage/whitelabel/root/favicon.png"
onerror="this.onerror=null;this.href='favicon.ico';" onerror="this.onerror=null;this.href='favicon.ico';"
/> /> -->
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
<!-- Tell the browser it's a PWA --> <!-- Tell the browser it's a PWA -->
@ -49,7 +48,7 @@
content="app-id=com.onlyoffice.documents" content="app-id=com.onlyoffice.documents"
/> />
<link <!-- <link
rel="apple-touch-icon" rel="apple-touch-icon"
href="/storage/whitelabel/root/favicon.png" href="/storage/whitelabel/root/favicon.png"
onerror="this.onerror=null;this.href='favicon.ico';" onerror="this.onerror=null;this.href='favicon.ico';"
@ -58,7 +57,7 @@
rel="android-touch-icon" rel="android-touch-icon"
href="/storage/whitelabel/root/favicon.png" href="/storage/whitelabel/root/favicon.png"
onerror="this.onerror=null;this.href='favicon.ico';" onerror="this.onerror=null;this.href='favicon.ico';"
/> /> -->
<!-- <%= htmlWebpackPlugin.options.custom %> --> <!-- <%= htmlWebpackPlugin.options.custom %> -->

View File

@ -33,7 +33,6 @@ import { useTranslation } from "react-i18next";
import { isMobile, isIOS, isFirefox } from "react-device-detect"; import { isMobile, isIOS, isFirefox } from "react-device-detect";
import { toast as toastify } from "react-toastify"; import { toast as toastify } from "react-toastify";
import { setFavicon } from "@docspace/shared/utils/favicon";
import { Portal } from "@docspace/shared/components/portal"; import { Portal } from "@docspace/shared/components/portal";
import { SnackBar } from "@docspace/shared/components/snackbar"; import { SnackBar } from "@docspace/shared/components/snackbar";
import { Toast, toastr } from "@docspace/shared/components/toast"; import { Toast, toastr } from "@docspace/shared/components/toast";
@ -130,11 +129,6 @@ const Shell = ({ items = [], page = "home", ...rest }) => {
moment.locale(language); moment.locale(language);
}, []); }, []);
useEffect(() => {
if (!whiteLabelLogoUrls) return;
setFavicon(whiteLabelLogoUrls);
}, [whiteLabelLogoUrls]);
useEffect(() => { useEffect(() => {
socketHelper.emit({ socketHelper.emit({
command: "subscribe", command: "subscribe",

View File

@ -36,7 +36,6 @@ import AppLoader from "@docspace/shared/components/app-loader";
import Error403 from "@docspace/shared/components/errors/Error403"; import Error403 from "@docspace/shared/components/errors/Error403";
import tryRedirectTo from "@docspace/shared/utils/tryRedirectTo"; import tryRedirectTo from "@docspace/shared/utils/tryRedirectTo";
import { setFavicon } from "@docspace/shared/utils/favicon";
import "@docspace/shared/styles/custom.scss"; import "@docspace/shared/styles/custom.scss";
@ -75,11 +74,6 @@ const App = observer(() => {
initData(); initData();
}, []); }, []);
useEffect(() => {
if (!whiteLabelLogoUrls) return;
setFavicon(whiteLabelLogoUrls);
}, [whiteLabelLogoUrls]);
useEffect(() => { useEffect(() => {
if (userTheme) setTheme(userTheme); if (userTheme) setTheme(userTheme);
}, [userTheme]); }, [userTheme]);

View File

@ -1,28 +0,0 @@
import { getLogoFromPath } from "./common";
import { TWhiteLabel } from "./whiteLabelHelper";
export const setFavicon = (whiteLabelLogoUrls: TWhiteLabel[]) => {
if (!whiteLabelLogoUrls) return;
const favicon = getLogoFromPath(whiteLabelLogoUrls[2]?.path?.light);
if (!favicon) return;
const link: HTMLLinkElement | null = document.querySelector("#favicon-icon");
if (link) link.href = favicon;
const shortcutIconLink: HTMLLinkElement | null =
document.querySelector("#favicon");
if (shortcutIconLink) shortcutIconLink.href = favicon;
const appleIconLink: HTMLLinkElement | null = document.querySelector(
"link[rel~='apple-touch-icon']",
);
if (appleIconLink) appleIconLink.href = favicon;
const androidIconLink: HTMLLinkElement | null = document.querySelector(
"link[rel~='android-touch-icon']",
);
if (androidIconLink) androidIconLink.href = favicon;
};