From 46c610990a2100901a3d4a2490bdb940e69a67b6 Mon Sep 17 00:00:00 2001 From: Dessalines <dessalines@users.noreply.github.com> Date: Thu, 23 Jun 2022 09:35:53 -0400 Subject: [PATCH] Expose pending 2 (#662) * Updating translations. * Adding better subscribe type. * Fix extra pending string. --- package.json | 2 +- src/shared/components/comment/comment-report.tsx | 3 ++- src/shared/components/community/communities.tsx | 11 +++++++++-- src/shared/components/community/sidebar.tsx | 12 +++++++++--- src/shared/components/post/post-report.tsx | 9 +++++++-- yarn.lock | 8 ++++---- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index f6ea01c..a643322 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "eslint-plugin-prettier": "^4.0.0", "husky": "^7.0.4", "import-sort-style-module": "^6.0.0", - "lemmy-js-client": "0.17.0-rc.30", + "lemmy-js-client": "0.17.0-rc.31", "lint-staged": "^12.4.1", "mini-css-extract-plugin": "^2.6.0", "node-fetch": "^2.6.1", diff --git a/src/shared/components/comment/comment-report.tsx b/src/shared/components/comment/comment-report.tsx index 98668e7..0a65226 100644 --- a/src/shared/components/comment/comment-report.tsx +++ b/src/shared/components/comment/comment-report.tsx @@ -5,6 +5,7 @@ import { CommentReportView, CommentView, ResolveCommentReport, + SubscribedType, } from "lemmy-js-client"; import { i18n } from "../../i18next"; import { CommentNode as CommentNodeI } from "../../interfaces"; @@ -40,7 +41,7 @@ export class CommentReport extends Component<CommentReportProps, any> { community: r.community, creator_banned_from_community: r.creator_banned_from_community, counts: r.counts, - subscribed: false, + subscribed: SubscribedType.NotSubscribed, saved: false, creator_blocked: false, recipient: None, diff --git a/src/shared/components/community/communities.tsx b/src/shared/components/community/communities.tsx index a9d4a6c..0ed2787 100644 --- a/src/shared/components/community/communities.tsx +++ b/src/shared/components/community/communities.tsx @@ -8,6 +8,7 @@ import { ListCommunitiesResponse, ListingType, SortType, + SubscribedType, UserOperation, wsJsonToRes, wsUserOp, @@ -183,7 +184,7 @@ export class Communities extends Component<any, CommunitiesState> { {numToSI(cv.counts.comments)} </td> <td class="text-right"> - {cv.subscribed ? ( + {cv.subscribed == SubscribedType.Subscribed && ( <button class="btn btn-link d-inline-block" onClick={linkEvent( @@ -193,7 +194,8 @@ export class Communities extends Component<any, CommunitiesState> { > {i18n.t("unsubscribe")} </button> - ) : ( + )} + {cv.subscribed == SubscribedType.NotSubscribed && ( <button class="btn btn-link d-inline-block" onClick={linkEvent( @@ -204,6 +206,11 @@ export class Communities extends Component<any, CommunitiesState> { {i18n.t("subscribe")} </button> )} + {cv.subscribed == SubscribedType.Pending && ( + <div class="text-warning d-inline-block"> + {i18n.t("subscribe_pending")} + </div> + )} </td> </tr> ))} diff --git a/src/shared/components/community/sidebar.tsx b/src/shared/components/community/sidebar.tsx index 159080a..91c7ba8 100644 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@ -9,6 +9,7 @@ import { FollowCommunity, PersonViewSafe, RemoveCommunity, + SubscribedType, toUndefined, } from "lemmy-js-client"; import { i18n } from "../../i18next"; @@ -111,7 +112,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { <BannerIconHeader icon={community.icon} banner={community.banner} /> )} <span class="mr-2">{community.title}</span> - {subscribed && ( + {subscribed == SubscribedType.Subscribed && ( <a class="btn btn-secondary btn-sm mr-2" href="#" @@ -121,6 +122,11 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { {i18n.t("joined")} </a> )} + {subscribed == SubscribedType.Pending && ( + <div class="badge badge-warning mr-2"> + {i18n.t("subscribe_pending")} + </div> + )} {community.removed && ( <small className="mr-2 text-muted font-italic"> {i18n.t("removed")} @@ -257,7 +263,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { createPost() { let cv = this.props.community_view; return ( - cv.subscribed && ( + cv.subscribed == SubscribedType.Subscribed && ( <Link className={`btn btn-secondary btn-block mb-2 ${ cv.community.deleted || cv.community.removed ? "no-click" : "" @@ -274,7 +280,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> { let community_view = this.props.community_view; return ( <div class="mb-2"> - {!community_view.subscribed && ( + {community_view.subscribed == SubscribedType.NotSubscribed && ( <a class="btn btn-secondary btn-block" href="#" diff --git a/src/shared/components/post/post-report.tsx b/src/shared/components/post/post-report.tsx index 1848761..220a5a9 100644 --- a/src/shared/components/post/post-report.tsx +++ b/src/shared/components/post/post-report.tsx @@ -1,7 +1,12 @@ import { None } from "@sniptt/monads"; import { Component, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; -import { PostReportView, PostView, ResolvePostReport } from "lemmy-js-client"; +import { + PostReportView, + PostView, + ResolvePostReport, + SubscribedType, +} from "lemmy-js-client"; import { i18n } from "../../i18next"; import { WebSocketService } from "../../services"; import { auth, wsClient } from "../../utils"; @@ -35,7 +40,7 @@ export class PostReport extends Component<PostReportProps, any> { community: r.community, creator_banned_from_community: r.creator_banned_from_community, counts: r.counts, - subscribed: false, + subscribed: SubscribedType.NotSubscribed, saved: false, read: false, creator_blocked: false, diff --git a/yarn.lock b/yarn.lock index 2b2fba4..571c0a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4948,10 +4948,10 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" -lemmy-js-client@0.17.0-rc.30: - version "0.17.0-rc.30" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.30.tgz#91cc926e662a5cd27f87cd2e6cdfcd210176745a" - integrity sha512-AcG8IZNNTa54BAXEqsL/QNlyPPwLntRLWpIOw9S3u84824d5inL7UCKnyx0UMbQklUuH/D3E2K9WNmZiUdvr3A== +lemmy-js-client@0.17.0-rc.31: + version "0.17.0-rc.31" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.31.tgz#373ad2dcbb1305bd82e7fb13704fbdb8d2f1c438" + integrity sha512-hcjFcOxgplffQullf9HuAGv2ko9wWySrnv+s8FWPPpg4EsixuBjXI+Dh7y0GR/KVs6fRmeXn4YBhR2YdJsBc7A== levn@^0.4.1: version "0.4.1" -- 2.44.1