From: Jay Sitter Date: Tue, 4 Jul 2023 00:02:24 +0000 (-0400) Subject: fix: Add data-bs-theme attribute for user dark/light modes (#1782) X-Git-Url: http://these/git/%22https:/join-lemmy.org/static/git-favicon.png?a=commitdiff_plain;h=b1292b958af008763028df9591f5778be9d117f5;p=lemmy-ui.git fix: Add data-bs-theme attribute for user dark/light modes (#1782) * fix: Add data-bs-theme attribute for user dark/light modes * fix: Remove unnecessary optional chain * fix: Oops -- add missing files --- diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index be0319d..3452f96 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -1,10 +1,11 @@ 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"; @@ -25,6 +26,13 @@ export class App extends Component { 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; @@ -32,7 +40,11 @@ export class App extends Component { return ( <> -
+