From: SleeplessOne1917 Date: Wed, 3 May 2023 16:09:47 +0000 (+0000) Subject: Handle when logged out (#986) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/README.es.md?a=commitdiff_plain;h=2e78191dae03288e6246f094648ba4d197c19967;p=lemmy-ui.git Handle when logged out (#986) * Add logged out messages to profile and community * Remove errors when not logged in * Add logged out translations --- diff --git a/lemmy-translations b/lemmy-translations index 5c50ce3..007e536 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit 5c50ce3ebaf058ad5d4e9bcd445653960cbc98b1 +Subproject commit 007e53683768aeba63e9e4c179c1d240217bcee2 diff --git a/src/shared/components/community/create-community.tsx b/src/shared/components/community/create-community.tsx index da8ef09..81c6253 100644 --- a/src/shared/components/community/create-community.tsx +++ b/src/shared/components/community/create-community.tsx @@ -1,8 +1,9 @@ import { Component } from "inferno"; +import { Redirect } from "inferno-router"; import { CommunityView, GetSiteResponse } from "lemmy-js-client"; import { Subscription } from "rxjs"; import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { UserService } from "../../services/UserService"; import { enableNsfw, isBrowser, @@ -32,11 +33,6 @@ export class CreateCommunity extends Component { this.parseMessage = this.parseMessage.bind(this); this.subscription = wsSubscribe(this.parseMessage); - - if (!UserService.Instance.myUserInfo && isBrowser()) { - toast(i18n.t("not_logged_in"), "danger"); - this.context.router.history.push(`/login`); - } } componentWillUnmount() { @@ -54,6 +50,7 @@ export class CreateCommunity extends Component { render() { return (
+ {!UserService.Instance.myUserInfo && } { } sidebar() { + const myUSerInfo = UserService.Instance.myUserInfo; + const { name, actor_id } = this.props.community_view.community; return (
{this.communityTitle()} {this.props.editable && this.adminButtons()} - {this.subscribe()} + {myUSerInfo && this.subscribe()} {this.canPost && this.createPost()} - {this.blockCommunity()} + {myUSerInfo && this.blockCommunity()} + {!myUSerInfo && ( +
+ {i18n.t("community_not_logged_in_alert", { + community: name, + instance: hostname(actor_id), + })} +
+ )}
@@ -123,7 +134,7 @@ export class Sidebar extends Component { )} {community.title} - {subscribed == SubscribedType.Subscribed && ( + {subscribed === SubscribedType.Subscribed && ( )} - {subscribed == SubscribedType.Pending && ( + {subscribed === SubscribedType.Pending && (
+ {!UserService.Instance.myUserInfo && ( +
+ {i18n.t("profile_not_logged_in_alert")} +
+ )}
diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index e40ca48..4fcca52 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -1,4 +1,5 @@ import { Component } from "inferno"; +import { Redirect } from "inferno-router"; import { RouteComponentProps } from "inferno-router/dist/Route"; import { GetCommunity, @@ -69,11 +70,6 @@ export class CreatePost extends Component< this.parseMessage = this.parseMessage.bind(this); this.subscription = wsSubscribe(this.parseMessage); - if (!UserService.Instance.myUserInfo && isBrowser()) { - toast(i18n.t("not_logged_in"), "danger"); - this.context.router.history.push(`/login`); - } - // Only fetch the data if coming from another route if (this.isoData.path === this.context.router.route.match.url) { const communityRes = this.isoData.routeData[0] as @@ -149,6 +145,7 @@ export class CreatePost extends Component< return (
+ {!UserService.Instance.myUserInfo && }