{this.mobileView()}
@@ -356,6 +350,7 @@ export class Home extends Component { mobileView() { let siteRes = this.state.siteRes; + let siteView = siteRes.site_view; return (
@@ -399,19 +394,15 @@ export class Home extends Component { classes="icon-inline" /> - {this.state.showSidebarMobile && - siteRes.site_view.match({ - some: siteView => ( - - ), - none: <>, - })} + {this.state.showSidebarMobile && ( + + )} {this.state.showTrendingMobile && (
{this.trendingCommunities()}
@@ -429,6 +420,7 @@ export class Home extends Component { mySidebar() { let siteRes = this.state.siteRes; + let siteView = siteRes.site_view; return (
{!this.state.loading && ( @@ -441,18 +433,13 @@ export class Home extends Component { {this.exploreCommunitiesButton()}
- {siteRes.site_view.match({ - some: siteView => ( - - ), - none: <>, - })} + {this.hasFollows && (
{this.subscribedCommunities()}
@@ -749,7 +736,7 @@ export class Home extends Component { this.setState({ trendingCommunities: data.communities }); } else if (op == UserOperation.EditSite) { let data = wsJsonToRes(msg, SiteResponse); - this.setState(s => ((s.siteRes.site_view = Some(data.site_view)), s)); + this.setState(s => ((s.siteRes.site_view = data.site_view), s)); toast(i18n.t("site_saved")); } else if (op == UserOperation.GetPosts) { let data = wsJsonToRes(msg, GetPostsResponse); diff --git a/src/shared/components/home/instances.tsx b/src/shared/components/home/instances.tsx index bd56c48..434fae9 100644 --- a/src/shared/components/home/instances.tsx +++ b/src/shared/components/home/instances.tsx @@ -21,10 +21,7 @@ export class Instances extends Component { } get documentTitle(): string { - return this.state.siteRes.site_view.match({ - some: siteView => `${i18n.t("instances")} - ${siteView.site.name}`, - none: "", - }); + return `${i18n.t("instances")} - ${this.state.siteRes.site_view.site.name}`; } render() { diff --git a/src/shared/components/home/legal.tsx b/src/shared/components/home/legal.tsx index bd07c40..3930db2 100644 --- a/src/shared/components/home/legal.tsx +++ b/src/shared/components/home/legal.tsx @@ -33,17 +33,10 @@ export class Legal extends Component { description={None} image={None} /> - {this.state.siteRes.site_view.match({ - some: siteView => - siteView.site.legal_information.match({ - some: legal => ( -
- ), - none: <>, - }), + {this.state.siteRes.site_view.local_site.legal_information.match({ + some: legal => ( +
+ ), none: <>, })}
diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 4cf9d4a..650b317 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -69,10 +69,7 @@ export class Login extends Component { } get documentTitle(): string { - return this.state.siteRes.site_view.match({ - some: siteView => `${i18n.t("login")} - ${siteView.site.name}`, - none: "", - }); + return `${i18n.t("login")} - ${this.state.siteRes.site_view.site.name}`; } get isLemmyMl(): boolean { @@ -194,6 +191,8 @@ export class Login extends Component { let data = wsJsonToRes(msg, LoginResponse); this.setState(this.emptyState); UserService.Instance.login(data); + this.props.history.push("/"); + location.reload(); } else if (op == UserOperation.PasswordReset) { toast(i18n.t("reset_password_mail_sent")); } else if (op == UserOperation.GetSite) { diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx index a288e2a..8da196c 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -2,6 +2,7 @@ import { None, Some } from "@sniptt/monads"; import { Component, linkEvent } from "inferno"; import { Helmet } from "inferno-helmet"; import { + GetSiteResponse, LoginResponse, Register, toUndefined, @@ -13,7 +14,7 @@ import { Subscription } from "rxjs"; import { delay, retryWhen, take } from "rxjs/operators"; import { i18n } from "../../i18next"; import { UserService, WebSocketService } from "../../services"; -import { toast, wsClient } from "../../utils"; +import { setIsoData, toast, wsClient } from "../../utils"; import { Spinner } from "../common/icon"; import { SiteForm } from "./site-form"; @@ -21,10 +22,12 @@ interface State { userForm: Register; doneRegisteringUser: boolean; userLoading: boolean; + siteRes: GetSiteResponse; } export class Setup extends Component { private subscription: Subscription; + private isoData = setIsoData(this.context); private emptyState: State = { userForm: new Register({ @@ -41,6 +44,7 @@ export class Setup extends Component { }), doneRegisteringUser: UserService.Instance.myUserInfo.isSome(), userLoading: false, + siteRes: this.isoData.site_res, }; constructor(props: any, context: any) { @@ -75,7 +79,7 @@ export class Setup extends Component { {!this.state.doneRegisteringUser ? ( this.registerUser() ) : ( - + )}
diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 5316211..2f62850 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -111,14 +111,14 @@ export class Signup extends Component { } get documentTitle(): string { - return this.state.siteRes.site_view.match({ - some: siteView => `${this.titleName(siteView)} - ${siteView.site.name}`, - none: "", - }); + let siteView = this.state.siteRes.site_view; + return `${this.titleName(siteView)} - ${siteView.site.name}`; } titleName(siteView: SiteView): string { - return i18n.t(siteView.site.private_instance ? "apply_to_join" : "sign_up"); + return i18n.t( + siteView.local_site.private_instance ? "apply_to_join" : "sign_up" + ); } get isLemmyMl(): boolean { @@ -144,248 +144,238 @@ export class Signup extends Component { } registerForm() { - return this.state.siteRes.site_view.match({ - some: siteView => ( -
-
{this.titleName(siteView)}
+ let siteView = this.state.siteRes.site_view; + return ( + +
{this.titleName(siteView)}
- {this.isLemmyMl && ( -
-
- - ## - -
+ {this.isLemmyMl && ( +
+
+ + ## +
- )} +
+ )} + +
+ + +
+ +
+
-
- +
+ +
+ + {!siteView.local_site.require_email_verification && + !this.state.registerForm.email.map(validEmail).unwrapOr(true) && ( +
+ + {i18n.t("no_password_reset")} +
+ )} +
+
-
- -
+
+ +
+ + {this.state.registerForm.password && ( +
+ {i18n.t(this.passwordStrength as I18nKeys)} +
+ )}
+
-
- -
- - {!siteView.site.require_email_verification && - !this.state.registerForm.email - .map(validEmail) - .unwrapOr(true) && ( -
- - {i18n.t("no_password_reset")} -
- )} -
+
+ +
+
+
-
- -
- - {this.state.registerForm.password && ( -
- {i18n.t(this.passwordStrength as I18nKeys)} + {siteView.local_site.require_application && ( + <> +
+
+
+ + {i18n.t("fill_out_application")}
- )} + {siteView.local_site.application_question.match({ + some: question => ( +
+ ), + none: <>, + })} +
-
+
+ +
+ +
+
+ + )} + + {this.state.captcha.isSome() && (
-