From 322a44bf24ec63bc2c0518ea7751e4a3a2f8e9e7 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Tue, 4 Jul 2023 20:53:28 +0000 Subject: [PATCH] Fix data-bs-theme (#1810) * Fix data-bs-theme * Add other dark themes * Add vaporwave-dark to dark theme list --- src/client/index.tsx | 4 ++-- src/server/handlers/catch-all-handler.tsx | 2 +- src/shared/components/app/app.tsx | 15 ++++++++------- src/shared/utils/browser/data-bs-theme.ts | 14 ++++++++++---- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/client/index.tsx b/src/client/index.tsx index 36059f97..2bdd948f 100644 --- a/src/client/index.tsx +++ b/src/client/index.tsx @@ -2,7 +2,7 @@ import { initializeSite, setupDateFns } from "@utils/app"; import { hydrate } from "inferno-hydrate"; import { Router } from "inferno-router"; import { App } from "../shared/components/app/app"; -import { HistoryService } from "../shared/services"; +import { HistoryService, UserService } from "../shared/services"; import "bootstrap/js/dist/collapse"; import "bootstrap/js/dist/dropdown"; @@ -14,7 +14,7 @@ async function startClient() { const wrapper = ( - + ); diff --git a/src/server/handlers/catch-all-handler.tsx b/src/server/handlers/catch-all-handler.tsx index 6b214944..4b011045 100644 --- a/src/server/handlers/catch-all-handler.tsx +++ b/src/server/handlers/catch-all-handler.tsx @@ -114,7 +114,7 @@ export default async (req: Request, res: Response) => { const wrapper = ( - + ); diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index 3452f962..2000bec2 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -3,6 +3,7 @@ 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 { MyUserInfo } from "lemmy-js-client"; import { IsoDataOptionalSite } from "../../interfaces"; import { routes } from "../../routes"; import { FirstLoadService, I18NextService, UserService } from "../../services"; @@ -14,10 +15,14 @@ import { Navbar } from "./navbar"; import "./styles.scss"; import { Theme } from "./theme"; -export class App extends Component { +interface AppProps { + user?: MyUserInfo; +} + +export class App extends Component { private isoData: IsoDataOptionalSite = setIsoData(this.context); private readonly mainContentRef: RefObject; - constructor(props: any, context: any) { + constructor(props: AppProps, context: any) { super(props, context); this.mainContentRef = createRef(); } @@ -29,10 +34,6 @@ export class App extends Component { user = UserService.Instance.myUserInfo; - componentDidMount() { - this.setState({ bsTheme: dataBsTheme(this.user) }); - } - render() { const siteRes = this.isoData.site_res; const siteView = siteRes?.site_view; @@ -43,7 +44,7 @@ export class App extends Component {