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";
const wrapper = (
<Router history={HistoryService.history}>
- <App />
+ <App user={UserService.Instance.myUserInfo} />
</Router>
);
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";
import "./styles.scss";
import { Theme } from "./theme";
-export class App extends Component<any, any> {
+interface AppProps {
+ user?: MyUserInfo;
+}
+
+export class App extends Component<AppProps, any> {
private isoData: IsoDataOptionalSite = setIsoData(this.context);
private readonly mainContentRef: RefObject<HTMLElement>;
- constructor(props: any, context: any) {
+ constructor(props: AppProps, context: any) {
super(props, context);
this.mainContentRef = createRef();
}
user = UserService.Instance.myUserInfo;
- componentDidMount() {
- this.setState({ bsTheme: dataBsTheme(this.user) });
- }
-
render() {
const siteRes = this.isoData.site_res;
const siteView = siteRes?.site_view;
<div
id="app"
className="lemmy-site"
- data-bs-theme={this.state?.bsTheme}
+ data-bs-theme={dataBsTheme(this.props.user)}
>
<button
type="button"
+import { MyUserInfo } from "lemmy-js-client";
import isDark from "./is-dark";
-export default function dataBsTheme(user) {
+export default function dataBsTheme(user?: MyUserInfo) {
return (isDark() && user?.local_user_view.local_user.theme === "browser") ||
(user &&
- ["darkly", "darkly-red", "darkly-pureblack"].includes(
- user.local_user_view.local_user.theme
- ))
+ [
+ "darkly",
+ "darkly-red",
+ "darkly-pureblack",
+ "darkly-compact",
+ "i386",
+ "vaporwave-dark",
+ ].includes(user.local_user_view.local_user.theme))
? "dark"
: "light";
}