From b12399de5fcbf75a18e515fce074788c850e6e6d Mon Sep 17 00:00:00 2001 From: abias Date: Sat, 3 Jun 2023 22:02:07 -0400 Subject: [PATCH 01/38] Make comments nested lists --- src/assets/css/main.css | 5 ++ .../components/comment/comment-node.tsx | 47 +++++++------------ .../components/comment/comment-nodes.tsx | 28 +++++++++-- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index a0d72394..5315aa37 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -213,6 +213,11 @@ blockquote { overflow-y: auto; } +.comments { + list-style: none; + padding: 0; +} + .thumbnail { object-fit: cover; min-height: 60px; diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index 7ed5e8f4..35ef33ac 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -159,18 +159,18 @@ export class CommentNode extends Component { } render() { - let node = this.props.node; - let cv = this.props.node.comment_view; + const node = this.props.node; + const cv = this.props.node.comment_view; - let purgeTypeText = + const purgeTypeText = this.state.purgeType == PurgeType.Comment ? i18n.t("purge_comment") : `${i18n.t("purge")} ${cv.creator.name}`; - let canMod_ = + const canMod_ = canMod(cv.creator.id, this.props.moderators, this.props.admins) && cv.community.local; - let canModOnSelf = + const canModOnSelf = canMod( cv.creator.id, this.props.moderators, @@ -178,59 +178,46 @@ export class CommentNode extends Component { UserService.Instance.myUserInfo, true ) && cv.community.local; - let canAdmin_ = + const canAdmin_ = canAdmin(cv.creator.id, this.props.admins) && cv.community.local; - let canAdminOnSelf = + const canAdminOnSelf = canAdmin( cv.creator.id, this.props.admins, UserService.Instance.myUserInfo, true ) && cv.community.local; - let isMod_ = isMod(cv.creator.id, this.props.moderators); - let isAdmin_ = + const isMod_ = isMod(cv.creator.id, this.props.moderators); + const isAdmin_ = isAdmin(cv.creator.id, this.props.admins) && cv.community.local; - let amCommunityCreator_ = amCommunityCreator( + const amCommunityCreator_ = amCommunityCreator( cv.creator.id, this.props.moderators ); - let borderColor = this.props.node.depth - ? colorList[(this.props.node.depth - 1) % colorList.length] - : colorList[0]; - let moreRepliesBorderColor = this.props.node.depth + const moreRepliesBorderColor = this.props.node.depth ? colorList[this.props.node.depth % colorList.length] : colorList[0]; - let showMoreChildren = + const showMoreChildren = this.props.viewType == CommentViewType.Tree && !this.state.collapsed && node.children.length == 0 && node.comment_view.counts.child_count > 0; return ( -
+
  • @@ -1024,11 +1011,13 @@ export class CommentNode extends Component { allLanguages={this.props.allLanguages} siteLanguages={this.props.siteLanguages} hideImages={this.props.hideImages} + isChild={!this.props.noIndent} + depth={this.props.node.depth + 1} /> )} {/* A collapsed clearfix */} - {this.state.collapsed &&
    } -
    + {this.state.collapsed &&
    } +
  • ); } diff --git a/src/shared/components/comment/comment-nodes.tsx b/src/shared/components/comment/comment-nodes.tsx index ba8997ac..11960da1 100644 --- a/src/shared/components/comment/comment-nodes.tsx +++ b/src/shared/components/comment/comment-nodes.tsx @@ -1,6 +1,8 @@ +import classNames from "classnames"; import { Component } from "inferno"; import { CommunityModeratorView, Language, PersonView } from "lemmy-js-client"; import { CommentNodeI, CommentViewType } from "../../interfaces"; +import { colorList } from "../../utils"; import { CommentNode } from "./comment-node"; interface CommentNodesProps { @@ -20,6 +22,8 @@ interface CommentNodesProps { allLanguages: Language[]; siteLanguages: number[]; hideImages?: boolean; + isChild?: boolean; + depth?: number; } export class CommentNodes extends Component { @@ -28,10 +32,24 @@ export class CommentNodes extends Component { } render() { - let maxComments = this.props.maxCommentsShown ?? this.props.nodes.length; + const maxComments = this.props.maxCommentsShown ?? this.props.nodes.length; - return ( -
    + const borderColor = this.props.depth + ? colorList[this.props.depth % colorList.length] + : colorList[0]; + + return this.props.nodes.length > 0 ? ( +
      {this.props.nodes.slice(0, maxComments).map(node => ( { hideImages={this.props.hideImages} /> ))} -
    - ); + + ) : null; } } From 48c16cc977957db400920ec355e9b5e535dda33a Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sat, 3 Jun 2023 23:49:49 -0400 Subject: [PATCH 02/38] Make comment depth easier to track visually --- src/shared/components/comment/comment-nodes.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/shared/components/comment/comment-nodes.tsx b/src/shared/components/comment/comment-nodes.tsx index 11960da1..64477fdf 100644 --- a/src/shared/components/comment/comment-nodes.tsx +++ b/src/shared/components/comment/comment-nodes.tsx @@ -41,14 +41,10 @@ export class CommentNodes extends Component { return this.props.nodes.length > 0 ? (
      {this.props.nodes.slice(0, maxComments).map(node => ( Date: Wed, 14 Jun 2023 10:12:32 +0200 Subject: [PATCH 03/38] add checkboxes to issue template --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 64579090..6ee32dea 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -9,6 +9,22 @@ body: Found a bug? Please fill out the sections below. 👍 Thanks for taking the time to fill out this bug report! For backend issues, use [lemmy](https://github.com/LemmyNet/lemmy) + - type: checkboxes + attributes: + label: Requirements + description: Before you create a bug report please do the following. + options: + - label: Did you check to see if this issue already exists? + required: true + options: + - label: Is this only a single bug. Do not put multiple bugs in one issue. + required: true + options: + - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support + required: true + options: + - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. + required: true - type: textarea id: summary attributes: From 9f337ecdeff9c651f6f23f4bd12d039e10e5babc Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 10:15:24 +0200 Subject: [PATCH 04/38] label array --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 6ee32dea..81a8e941 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -15,16 +15,11 @@ body: description: Before you create a bug report please do the following. options: - label: Did you check to see if this issue already exists? - required: true - options: - label: Is this only a single bug. Do not put multiple bugs in one issue. - required: true - options: - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support - required: true - options: - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. - required: true + validations: + required: true - type: textarea id: summary attributes: From 040d56a1a2122835f314efde1d223090265a485c Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 10:16:45 +0200 Subject: [PATCH 05/38] indent validations --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 81a8e941..67e3b765 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -18,8 +18,8 @@ body: - label: Is this only a single bug. Do not put multiple bugs in one issue. - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. - validations: - required: true + validations: + required: true - type: textarea id: summary attributes: From 152aaf77b0e86b24c2d1d29d07732e7f054d7ec3 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 10:19:04 +0200 Subject: [PATCH 06/38] required under label --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 67e3b765..5bb68ebc 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -15,11 +15,13 @@ body: description: Before you create a bug report please do the following. options: - label: Did you check to see if this issue already exists? + required: true - label: Is this only a single bug. Do not put multiple bugs in one issue. + required: true - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support + required: true - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. - validations: - required: true + required: true - type: textarea id: summary attributes: From fd123d4f48b1c713fd6627c9fc43044c58a83f67 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 10:22:46 +0200 Subject: [PATCH 07/38] add checkboxes to feature requests --- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml index 375d06d3..fa026019 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml @@ -7,6 +7,19 @@ body: value: | Have a suggestion about Lemmy's UI? For backend issues, use [lemmy](https://github.com/LemmyNet/lemmy) + - type: checkboxes + attributes: + label: Requirements + description: Before you create a bug report please do the following. + options: + - label: Did you check to see if this issue already exists? + required: true + - label: Is this only a feature request. Do not put multiple feature requests in one issue. + required: true + - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support + required: true + - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. + required: true - type: textarea id: problem attributes: From 6517d99bfb890a0883de1466d85ca2ab768810a6 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 10:31:11 +0200 Subject: [PATCH 08/38] prettier --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 2 +- .github/ISSUE_TEMPLATE/QUESTION.yml | 2 +- .github/ISSUE_TEMPLATE/hexbear.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 5bb68ebc..2611bf90 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -35,7 +35,7 @@ body: label: Steps to Reproduce description: | Describe the steps to reproduce the bug. - The better your description is _(go 'here', click 'there'...)_ the fastest you'll get an _(accurate)_ resolution. + The better your description is _(go 'here', click 'there'...)_ the fastest you'll get an _(accurate)_ resolution. value: | 1. 2. diff --git a/.github/ISSUE_TEMPLATE/QUESTION.yml b/.github/ISSUE_TEMPLATE/QUESTION.yml index 460d9a44..734937e9 100644 --- a/.github/ISSUE_TEMPLATE/QUESTION.yml +++ b/.github/ISSUE_TEMPLATE/QUESTION.yml @@ -14,4 +14,4 @@ body: label: Question description: What's the question you have about Lemmy's UI? validations: - required: true \ No newline at end of file + required: true diff --git a/.github/ISSUE_TEMPLATE/hexbear.yml b/.github/ISSUE_TEMPLATE/hexbear.yml index 199b97e9..73ef5482 100644 --- a/.github/ISSUE_TEMPLATE/hexbear.yml +++ b/.github/ISSUE_TEMPLATE/hexbear.yml @@ -8,4 +8,4 @@ body: label: Question description: What's the question you have about hexbear? validations: - required: true \ No newline at end of file + required: true From 2d91d31517fceedc127f308bfca06fd0e3f80c83 Mon Sep 17 00:00:00 2001 From: Raymond Berger Date: Wed, 14 Jun 2023 11:18:43 +0200 Subject: [PATCH 09/38] Update BUG_REPORT.yml --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 2611bf90..c311da4b 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -16,7 +16,7 @@ body: options: - label: Did you check to see if this issue already exists? required: true - - label: Is this only a single bug. Do not put multiple bugs in one issue. + - label: Is this only a single bug? Do not put multiple bugs in one issue. required: true - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support required: true From eed88764845719945062c4d1da9662358fce6001 Mon Sep 17 00:00:00 2001 From: Raymond Berger Date: Wed, 14 Jun 2023 11:24:17 +0200 Subject: [PATCH 10/38] make question clearer --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index c311da4b..0594a03f 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -18,7 +18,7 @@ body: required: true - label: Is this only a single bug? Do not put multiple bugs in one issue. required: true - - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support + - label: Is this a bug report? For questions or discussions, use https://lemmy.ml/c/lemmy_support required: true - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. required: true From 58954e5bee7c9b4656ea705a2a63a8cef434f0ce Mon Sep 17 00:00:00 2001 From: Raymond Berger Date: Wed, 14 Jun 2023 11:25:49 +0200 Subject: [PATCH 11/38] improve q for feature request --- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml index fa026019..343a7df9 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml @@ -14,9 +14,9 @@ body: options: - label: Did you check to see if this issue already exists? required: true - - label: Is this only a feature request. Do not put multiple feature requests in one issue. + - label: Is this only a feature request? Do not put multiple feature requests in one issue. required: true - - label: Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support + - label: Is this a feature request? For questions or discussions, use https://lemmy.ml/c/lemmy_support required: true - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. required: true From 1f04febd11bb778b2f0046c78a53785f5324ce04 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 11:39:18 +0200 Subject: [PATCH 12/38] reorder questions --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 4 ++-- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 0594a03f..0000138e 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -14,12 +14,12 @@ body: label: Requirements description: Before you create a bug report please do the following. options: + - label: Is this a bug report? For questions or discussions, use https://lemmy.ml/c/lemmy_support + required: true - label: Did you check to see if this issue already exists? required: true - label: Is this only a single bug? Do not put multiple bugs in one issue. required: true - - label: Is this a bug report? For questions or discussions, use https://lemmy.ml/c/lemmy_support - required: true - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. required: true - type: textarea diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml index 343a7df9..848b819c 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml @@ -12,12 +12,12 @@ body: label: Requirements description: Before you create a bug report please do the following. options: + - label: Is this a feature request? For questions or discussions, use https://lemmy.ml/c/lemmy_support + required: true - label: Did you check to see if this issue already exists? required: true - label: Is this only a feature request? Do not put multiple feature requests in one issue. required: true - - label: Is this a feature request? For questions or discussions, use https://lemmy.ml/c/lemmy_support - required: true - label: Is this a server side (not related to the UI) issue? Use the [Lemmy back end](https://github.com/LemmyNet/lemmy) repo. required: true - type: textarea From 97ef46a256e7a6d7e33b9b5f8144661c1036ff80 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 11:41:56 +0200 Subject: [PATCH 13/38] no comma --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 2 +- .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index 0000138e..a07b80a5 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -14,7 +14,7 @@ body: label: Requirements description: Before you create a bug report please do the following. options: - - label: Is this a bug report? For questions or discussions, use https://lemmy.ml/c/lemmy_support + - label: Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support required: true - label: Did you check to see if this issue already exists? required: true diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml index 848b819c..2f6f3fc1 100644 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.yml @@ -12,7 +12,7 @@ body: label: Requirements description: Before you create a bug report please do the following. options: - - label: Is this a feature request? For questions or discussions, use https://lemmy.ml/c/lemmy_support + - label: Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support required: true - label: Did you check to see if this issue already exists? required: true From 374629f689e782a320c01774db8376dfbf320ea2 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 14 Jun 2023 12:06:26 +0200 Subject: [PATCH 14/38] add instance url --- .github/ISSUE_TEMPLATE/BUG_REPORT.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml index a07b80a5..2273a138 100644 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.yml +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.yml @@ -58,3 +58,9 @@ body: placeholder: ex. 0.17.4-rc.4 validations: required: true + - type: input + id: lemmy-instance + attributes: + label: Lemmy Instance URL + description: Which Lemmy instance do you use? The address + placeholder: lemmy.ml, lemmy.world, etc From be60dae9f8d8355580fe065ef8aadd3f6fdcf3cd Mon Sep 17 00:00:00 2001 From: Camel Coder <69110542+camel-cdr@users.noreply.github.com> Date: Wed, 14 Jun 2023 12:00:13 +0000 Subject: [PATCH 15/38] Horizontally scrollable code blocks, instead of wrapping. This disables word wrapping for code generated from markdown, and instead enables a horizontal scroll bar. --- src/assets/css/main.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/assets/css/main.css b/src/assets/css/main.css index 1c45341d..3ff70e47 100644 --- a/src/assets/css/main.css +++ b/src/assets/css/main.css @@ -75,6 +75,11 @@ font-size: 1.2rem; } +.md-div pre { + white-space: pre; + overflow-x: auto; +} + .md-div table { border-collapse: collapse; width: 100%; From b076427e8dcd4d93fd56c1bb2cc005055e661216 Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 09:32:25 -0400 Subject: [PATCH 16/38] handle loading state on community-form.tsx --- src/shared/components/community/community-form.tsx | 12 +++++------- src/shared/components/community/create-community.tsx | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/shared/components/community/community-form.tsx b/src/shared/components/community/community-form.tsx index f317c983..1d32f6f7 100644 --- a/src/shared/components/community/community-form.tsx +++ b/src/shared/components/community/community-form.tsx @@ -21,6 +21,7 @@ interface CommunityFormProps { onCancel?(): any; onUpsertCommunity(form: CreateCommunity | EditCommunity): void; enableNsfw?: boolean; + isLoading?: boolean; } interface CommunityFormState { @@ -34,7 +35,6 @@ interface CommunityFormState { posting_restricted_to_mods?: boolean; discussion_languages?: number[]; }; - loading: boolean; submitted: boolean; } @@ -46,7 +46,6 @@ export class CommunityForm extends Component< state: CommunityFormState = { form: {}, - loading: false, submitted: false, }; @@ -80,7 +79,6 @@ export class CommunityForm extends Component< posting_restricted_to_mods: cv.community.posting_restricted_to_mods, discussion_languages: this.props.communityLanguages, }, - loading: false, }; } } @@ -90,7 +88,7 @@ export class CommunityForm extends Component<
      - {this.state.loading ? ( + {this.props.isLoading ? ( ) : this.props.community_view ? ( capitalizeFirstLetter(i18n.t("save")) @@ -270,7 +268,7 @@ export class CommunityForm extends Component< handleCreateCommunitySubmit(i: CommunityForm, event: any) { event.preventDefault(); - i.setState({ loading: true, submitted: true }); + i.setState({ submitted: true }); const cForm = i.state.form; const auth = myAuthRequired(); diff --git a/src/shared/components/community/create-community.tsx b/src/shared/components/community/create-community.tsx index f75c4fbb..ecadd3a1 100644 --- a/src/shared/components/community/create-community.tsx +++ b/src/shared/components/community/create-community.tsx @@ -11,12 +11,14 @@ import { CommunityForm } from "./community-form"; interface CreateCommunityState { siteRes: GetSiteResponse; + loading: boolean; } export class CreateCommunity extends Component { private isoData = setIsoData(this.context); state: CreateCommunityState = { siteRes: this.isoData.site_res, + loading: false, }; constructor(props: any, context: any) { super(props, context); @@ -45,6 +47,7 @@ export class CreateCommunity extends Component { allLanguages={this.state.siteRes.all_languages} siteLanguages={this.state.siteRes.discussion_languages} communityLanguages={this.state.siteRes.discussion_languages} + isLoading={this.state.loading} />
    @@ -53,10 +56,15 @@ export class CreateCommunity extends Component { } async handleCommunityCreate(form: CreateCommunityI) { + this.setState({ loading: true }); + const res = await HttpService.client.createCommunity(form); + if (res.state === "success") { const name = res.data.community_view.community.name; this.props.history.replace(`/c/${name}`); + } else { + this.setState({ loading: false }); } } } From cd9de0b2e0964e5279c03d6e2e5383ba6f07d35a Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 09:39:19 -0400 Subject: [PATCH 17/38] update prop name --- src/shared/components/community/community-form.tsx | 8 ++++---- src/shared/components/community/create-community.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shared/components/community/community-form.tsx b/src/shared/components/community/community-form.tsx index 1d32f6f7..4eed4645 100644 --- a/src/shared/components/community/community-form.tsx +++ b/src/shared/components/community/community-form.tsx @@ -21,7 +21,7 @@ interface CommunityFormProps { onCancel?(): any; onUpsertCommunity(form: CreateCommunity | EditCommunity): void; enableNsfw?: boolean; - isLoading?: boolean; + loading?: boolean; } interface CommunityFormState { @@ -88,7 +88,7 @@ export class CommunityForm extends Component< - {this.props.isLoading ? ( + {this.props.loading ? ( ) : this.props.community_view ? ( capitalizeFirstLetter(i18n.t("save")) diff --git a/src/shared/components/community/create-community.tsx b/src/shared/components/community/create-community.tsx index ecadd3a1..ff31b839 100644 --- a/src/shared/components/community/create-community.tsx +++ b/src/shared/components/community/create-community.tsx @@ -47,7 +47,7 @@ export class CreateCommunity extends Component { allLanguages={this.state.siteRes.all_languages} siteLanguages={this.state.siteRes.discussion_languages} communityLanguages={this.state.siteRes.discussion_languages} - isLoading={this.state.loading} + loading={this.state.loading} /> From 520efdcadaab0eff3c50f78d1bbc9412c072d4fe Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 09:47:33 -0400 Subject: [PATCH 18/38] trim all username state input --- src/shared/components/home/login.tsx | 2 +- src/shared/components/home/setup.tsx | 2 +- src/shared/components/home/signup.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 87ef234e..94915542 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -195,7 +195,7 @@ export class Login extends Component { } handleLoginUsernameChange(i: Login, event: any) { - i.state.form.username_or_email = event.target.value; + i.state.form.username_or_email = event.target.value.trim(); i.setState(i.state); } diff --git a/src/shared/components/home/setup.tsx b/src/shared/components/home/setup.tsx index 581c1c56..14350a58 100644 --- a/src/shared/components/home/setup.tsx +++ b/src/shared/components/home/setup.tsx @@ -221,7 +221,7 @@ export class Setup extends Component { } handleRegisterUsernameChange(i: Setup, event: any) { - i.state.form.username = event.target.value; + i.state.form.username = event.target.value.trim(); i.setState(i.state); } diff --git a/src/shared/components/home/signup.tsx b/src/shared/components/home/signup.tsx index 3efeac62..16a3cc6d 100644 --- a/src/shared/components/home/signup.tsx +++ b/src/shared/components/home/signup.tsx @@ -496,7 +496,7 @@ export class Signup extends Component { } handleRegisterUsernameChange(i: Signup, event: any) { - i.state.form.username = event.target.value; + i.state.form.username = event.target.value.trim(); i.setState(i.state); } From 99f81f8d638d2976178ba71c66fa3ba069912b96 Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 10:03:00 -0400 Subject: [PATCH 19/38] adds missing tooltip --- src/shared/components/post/post-listing.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index f1f06c58..d5fc785c 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -835,6 +835,8 @@ export class PostListing extends Component { search: "", }} title={i18n.t("cross_post")} + data-tippy-content={i18n.t("cross_post")} + aria-label={i18n.t("cross_post")} > From d75e4365c4ff79568d2c4b38f208e6b2b5a549d5 Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 16:29:04 -0400 Subject: [PATCH 20/38] remove pictrsDeleteToast usage from PostForm, add delete image button, fix infinite loading bug if upload error occured --- src/shared/components/post/post-form.tsx | 45 +++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index 3ce96bb0..cef8e294 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -25,7 +25,6 @@ import { isImage, myAuth, myAuthRequired, - pictrsDeleteToast, relTags, setupTippy, toast, @@ -73,6 +72,7 @@ interface PostFormState { suggestedPostsRes: RequestState; metadataRes: RequestState; imageLoading: boolean; + imageDeleteUrl: string; communitySearchLoading: boolean; communitySearchOptions: Choice[]; previewMode: boolean; @@ -86,6 +86,7 @@ export class PostForm extends Component { form: {}, loading: false, imageLoading: false, + imageDeleteUrl: "", communitySearchLoading: false, previewMode: false, communitySearchOptions: [], @@ -269,6 +270,17 @@ export class PostForm extends Component { {url && isImage(url) && ( )} + {this.state.imageDeleteUrl && ( + + )} {this.props.crossPosts && this.props.crossPosts.length > 0 && ( <>
    @@ -553,7 +565,15 @@ export class PostForm extends Component { } handlePostUrlChange(i: PostForm, event: any) { - i.setState(s => ((s.form.url = event.target.value), s)); + const url = event.target.value; + + i.setState({ + form: { + url, + }, + imageDeleteUrl: "", + }); + i.fetchPageTitle(); } @@ -644,18 +664,35 @@ export class PostForm extends Component { if (res.state === "success") { if (res.data.msg === "ok") { i.state.form.url = res.data.url; - pictrsDeleteToast(file.name, res.data.delete_url as string); - i.setState({ imageLoading: false }); + i.setState({ + imageLoading: false, + imageDeleteUrl: res.data.delete_url as string, + }); } else { toast(JSON.stringify(res), "danger"); } } else if (res.state === "failed") { console.error(res.msg); toast(res.msg, "danger"); + i.setState({ imageLoading: false }); } }); } + handleImageDelete(i: PostForm) { + const { imageDeleteUrl } = i.state; + + fetch(imageDeleteUrl); + + i.setState({ + imageDeleteUrl: "", + imageLoading: false, + form: { + url: "", + }, + }); + } + handleCommunitySearch = debounce(async (text: string) => { const { selectedCommunityChoice } = this.props; this.setState({ communitySearchLoading: true }); From 44e45bb84da4651f1a775d909503d9e8f8b9627f Mon Sep 17 00:00:00 2001 From: Alec Armbruster Date: Wed, 14 Jun 2023 16:45:56 -0400 Subject: [PATCH 21/38] make button a tad smaller --- src/shared/components/post/post-form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx index cef8e294..4640922d 100644 --- a/src/shared/components/post/post-form.tsx +++ b/src/shared/components/post/post-form.tsx @@ -272,7 +272,7 @@ export class PostForm extends Component { )} {this.state.imageDeleteUrl && (
    {showMoreChildren && (