import { isAuthPath, setIsoData } from "@utils/app";
+import { dataBsTheme } from "@utils/browser";
import { Component, RefObject, createRef, linkEvent } from "inferno";
import { Provider } from "inferno-i18next-dess";
import { Route, Switch } from "inferno-router";
import { IsoDataOptionalSite } from "../../interfaces";
import { routes } from "../../routes";
-import { FirstLoadService, I18NextService } from "../../services";
+import { FirstLoadService, I18NextService, UserService } from "../../services";
import AuthGuard from "../common/auth-guard";
import ErrorGuard from "../common/error-guard";
import { ErrorPage } from "./error-page";
event.preventDefault();
this.mainContentRef.current?.focus();
}
+
+ user = UserService.Instance.myUserInfo;
+
+ componentDidMount() {
+ this.setState({ bsTheme: dataBsTheme(this.user) });
+ }
+
render() {
const siteRes = this.isoData.site_res;
const siteView = siteRes?.site_view;
return (
<>
<Provider i18next={I18NextService.i18n}>
- <div id="app" className="lemmy-site">
+ <div
+ id="app"
+ className="lemmy-site"
+ data-bs-theme={this.state?.bsTheme}
+ >
<button
type="button"
className="btn skip-link bg-light position-absolute start-0 z-3"
--- /dev/null
+import isDark from "./is-dark";
+
+export default function dataBsTheme(user) {
+ return (isDark() && user?.local_user_view.local_user.theme === "browser") ||
+ (user &&
+ ["darkly", "darkly-red", "darkly-pureblack"].includes(
+ user.local_user_view.local_user.theme
+ ))
+ ? "dark"
+ : "light";
+}
import canShare from "./can-share";
+import dataBsTheme from "./data-bs-theme";
import isBrowser from "./is-browser";
+import isDark from "./is-dark";
import loadCss from "./load-css";
import restoreScrollPosition from "./restore-scroll-position";
import saveScrollPosition from "./save-scroll-position";
export {
canShare,
+ dataBsTheme,
isBrowser,
+ isDark,
loadCss,
restoreScrollPosition,
saveScrollPosition,