X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fapp%2Fapp.tsx;h=3452f9627c3159d672b676b98b75e3a8c0d166f8;hb=b1292b958af008763028df9591f5778be9d117f5;hp=79aa77eb2dc07a0d2930f4c6ec3dfa6098839fc7;hpb=e6005daadfa74e157cebef22defd3a164eef5120;p=lemmy-ui.git diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index 79aa77e..3452f96 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -1,10 +1,11 @@ -import { Component, createRef, linkEvent, RefObject } from "inferno"; +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 { i18n } from "../../i18next"; import { IsoDataOptionalSite } from "../../interfaces"; import { routes } from "../../routes"; -import { isAuthPath, setIsoData } from "../../utils"; +import { FirstLoadService, I18NextService, UserService } from "../../services"; import AuthGuard from "../common/auth-guard"; import ErrorGuard from "../common/error-guard"; import { ErrorPage } from "./error-page"; @@ -25,47 +26,67 @@ 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; return ( <> - -
- +
+ {siteView && ( )}
- {routes.map(({ path, component: RouteComponent }) => ( - ( - -
- {RouteComponent && - (isAuthPath(path ?? "") ? ( - - - - ) : ( - - ))} -
-
- )} - /> - ))} + {routes.map( + ({ path, component: RouteComponent, fetchInitialData }) => ( + { + if (!fetchInitialData) { + FirstLoadService.falsify(); + } + + return ( + +
+ {RouteComponent && + (isAuthPath(path ?? "") ? ( + + + + ) : ( + + ))} +
+
+ ); + }} + /> + ) + )}