mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-19 20:50:09 +01:00
6a2d7aca28
* implement custom icon on login screen for single & multi user + custom app name feature * hide field when not relevant * set customApp name * show original anythingllm login logo unless custom logo is set * nit-picks * remove console log --------- Co-authored-by: timothycarambat <rambat1010@gmail.com>
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import { createContext, useEffect, useState } from "react";
|
|
import AnythingLLM from "./media/logo/anything-llm.png";
|
|
import DefaultLoginLogo from "./media/illustrations/login-logo.svg";
|
|
import System from "./models/system";
|
|
|
|
export const LogoContext = createContext();
|
|
|
|
export function LogoProvider({ children }) {
|
|
const [logo, setLogo] = useState("");
|
|
const [loginLogo, setLoginLogo] = useState("");
|
|
const [isCustomLogo, setIsCustomLogo] = useState(false);
|
|
|
|
useEffect(() => {
|
|
async function fetchInstanceLogo() {
|
|
try {
|
|
const { isCustomLogo, logoURL } = await System.fetchLogo();
|
|
if (logoURL) {
|
|
setLogo(logoURL);
|
|
setLoginLogo(isCustomLogo ? logoURL : DefaultLoginLogo);
|
|
setIsCustomLogo(isCustomLogo);
|
|
} else {
|
|
setLogo(AnythingLLM);
|
|
setLoginLogo(DefaultLoginLogo);
|
|
setIsCustomLogo(false);
|
|
}
|
|
} catch (err) {
|
|
setLogo(AnythingLLM);
|
|
setLoginLogo(DefaultLoginLogo);
|
|
setIsCustomLogo(false);
|
|
console.error("Failed to fetch logo:", err);
|
|
}
|
|
}
|
|
|
|
fetchInstanceLogo();
|
|
}, []);
|
|
|
|
return (
|
|
<LogoContext.Provider value={{ logo, setLogo, loginLogo, isCustomLogo }}>
|
|
{children}
|
|
</LogoContext.Provider>
|
|
);
|
|
}
|