From 235843f96f5013569b2085b21a495fdb83dd296e Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Fri, 21 Jul 2023 21:50:13 -0400 Subject: [PATCH] Add card to federation success page --- src/assets/css/main.css | 1 - src/shared/components/app/app.tsx | 2 +- src/shared/components/common/pictrs-image.tsx | 27 ++-- .../components/common/subscribe-button.tsx | 68 +++++++++++ src/shared/components/community/sidebar.tsx | 72 ++--------- src/shared/components/remote-fetch.tsx | 115 ++++++++++++++++-- 6 files changed, 200 insertions(+), 85 deletions(-) create mode 100644 src/shared/components/common/subscribe-button.tsx diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 17495e07..36566b9b 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -249,7 +249,6 @@ hr { .fl-1 { flex: 1; - display: flex; } .img-blur { diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index 70f30c37..180ca25e 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -72,7 +72,7 @@ export class App extends Component { return ( -
+
{RouteComponent && (isAuthPath(path ?? "") ? ( diff --git a/src/shared/components/common/pictrs-image.tsx b/src/shared/components/common/pictrs-image.tsx index 5c3d823d..867277ce 100644 --- a/src/shared/components/common/pictrs-image.tsx +++ b/src/shared/components/common/pictrs-image.tsx @@ -13,6 +13,7 @@ interface PictrsImageProps { nsfw?: boolean; iconOverlay?: boolean; pushup?: boolean; + cardTop?: boolean; } export class PictrsImage extends Component { @@ -21,28 +22,30 @@ export class PictrsImage extends Component { } render() { + const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } = + this.props; + return ( - + {this.alt()} diff --git a/src/shared/components/common/subscribe-button.tsx b/src/shared/components/common/subscribe-button.tsx new file mode 100644 index 00000000..258a97ae --- /dev/null +++ b/src/shared/components/common/subscribe-button.tsx @@ -0,0 +1,68 @@ +import { NoOptionI18nKeys } from "i18next"; +import { MouseEventHandler } from "inferno"; +import { SubscribedType } from "lemmy-js-client"; +import { I18NextService, UserService } from "../../services"; +import { Icon, Spinner } from "./icon"; + +interface SubscribeButtonProps { + subscribed: SubscribedType; + onFollow: MouseEventHandler; + onUnFollow: MouseEventHandler; + loading: boolean; +} + +export function SubscribeButton({ + subscribed, + onFollow, + onUnFollow, + loading, +}: SubscribeButtonProps) { + let i18key: NoOptionI18nKeys; + + switch (subscribed) { + case "NotSubscribed": { + i18key = "subscribe"; + + break; + } + case "Subscribed": { + i18key = "joined"; + + break; + } + default: { + i18key = "subscribe_pending"; + + break; + } + } + + if (!UserService.Instance.myUserInfo) { + return ( + + ); + } + + return ( + + ); +} diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index 065377d0..5228a3cd 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -1,7 +1,6 @@ import { myAuthRequired } from "@utils/app"; import { getUnixTime, hostname } from "@utils/helpers"; import { amAdmin, amMod, amTopMod } from "@utils/roles"; -import { NoOptionI18nKeys } from "i18next"; import { Component, InfernoNode, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; import { Link } from "inferno-router"; @@ -23,6 +22,7 @@ import { I18NextService, UserService } from "../../services"; import { Badges } from "../common/badges"; import { BannerIconHeader } from "../common/banner-icon-header"; import { Icon, PurgeWarning, Spinner } from "../common/icon"; +import { SubscribeButton } from "../common/subscribe-button"; import { CommunityForm } from "../community/community-form"; import { CommunityLink } from "../community/community-link"; import { PersonListing } from "../person/person-listing"; @@ -124,7 +124,10 @@ export class Sidebar extends Component { sidebar() { const myUSerInfo = UserService.Instance.myUserInfo; - const { name, actor_id } = this.props.community_view.community; + const { + community: { name, actor_id }, + subscribed, + } = this.props.community_view; return (