From 2bebc0db25b3af9d47857df8d8a6ccba43abd09a Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 19 Feb 2024 21:08:14 +0100 Subject: [PATCH 01/11] style(subplebbit settings): add word wrap to description preview --- .../subplebbit-settings/subplebbit-settings.module.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css index 91050ba6..28c007f7 100644 --- a/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css +++ b/src/views/subplebbit/subplebbit-settings/subplebbit-settings.module.css @@ -77,6 +77,7 @@ .descriptionPreviewMarkdown { width: 300px; + word-wrap: break-word; font-size: 12px; } From dfc7afde76686eda467c83aaadda5400695d59ba Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Mon, 19 Feb 2024 21:10:26 +0100 Subject: [PATCH 02/11] chore(notifications.yml): comment out for now, using IFTTT instead --- .github/workflows/notifications.yml | 166 ++++++++++++++-------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/.github/workflows/notifications.yml b/.github/workflows/notifications.yml index 68aeed7f..e8603387 100644 --- a/.github/workflows/notifications.yml +++ b/.github/workflows/notifications.yml @@ -1,93 +1,93 @@ -# send notifications to telegram group on commits, releases, issues -name: notifications +# # send notifications to telegram group on commits, releases, issues +# name: notifications -on: - pull_request: - branches: - - master - push: - branches: - - master - release: - types: [published] - issues: - types: [opened] +# on: +# pull_request: +# branches: +# - master +# push: +# branches: +# - master +# release: +# types: [published] +# issues: +# types: [opened] -jobs: - push: - if: ${{ github.event_name == 'push' }} - runs-on: ubuntu-latest - strategy: - matrix: - commit: ${{ github.event.commits }} - steps: - # - name: debug - # env: - # DEBUG: ${{ toJSON(matrix.commit) }} - # run: echo "$DEBUG" +# jobs: +# push: +# if: ${{ github.event_name == 'push' }} +# runs-on: ubuntu-latest +# strategy: +# matrix: +# commit: ${{ github.event.commits }} +# steps: +# # - name: debug +# # env: +# # DEBUG: ${{ toJSON(matrix.commit) }} +# # run: echo "$DEBUG" - # write message to file - - run: echo "${{ matrix.commit.message }}" >> message.txt - - run: echo "" >> message.txt - - run: echo "by ${{ matrix.commit.author.username }}" >> message.txt - - run: echo "${{ matrix.commit.url }}" >> message.txt - - run: date -d "${{ matrix.commit.timestamp }}" +"%d/%m/%y at %H:%M" >> message.txt +# # write message to file +# - run: echo "${{ matrix.commit.message }}" >> message.txt +# - run: echo "" >> message.txt +# - run: echo "by ${{ matrix.commit.author.username }}" >> message.txt +# - run: echo "${{ matrix.commit.url }}" >> message.txt +# - run: date -d "${{ matrix.commit.timestamp }}" +"%d/%m/%y at %H:%M" >> message.txt - # send message, @plebbit telegram chat id is -1001665335693 - - name: "telegram notification" - uses: appleboy/telegram-action@master - with: - to: -1001665335693 - token: ${{ secrets.TELEGRAM_TOKEN }} - # commit links don't show anything useful in preview - disable_web_page_preview: true - format: html - message_file: message.txt +# # send message, @plebbit telegram chat id is -1001665335693 +# - name: "telegram notification" +# uses: appleboy/telegram-action@master +# with: +# to: -1001665335693 +# token: ${{ secrets.TELEGRAM_TOKEN }} +# # commit links don't show anything useful in preview +# disable_web_page_preview: true +# format: html +# message_file: message.txt - release: - if: ${{ github.event_name == 'release' }} - runs-on: ubuntu-latest - steps: - # - name: debug - # env: - # DEBUG: ${{ toJSON(github) }} - # run: echo "$DEBUG" +# release: +# if: ${{ github.event_name == 'release' }} +# runs-on: ubuntu-latest +# steps: +# # - name: debug +# # env: +# # DEBUG: ${{ toJSON(github) }} +# # run: echo "$DEBUG" - # write message to file - - run: echo "${{ github.event.repository.name }} ${{ github.event.release.name }}" >> message.txt - - run: echo "" >> message.txt - - run: echo "${{ github.event.release.body }}" >> message.txt - - run: echo "${{ github.event.release.html_url }}" >> message.txt +# # write message to file +# - run: echo "${{ github.event.repository.name }} ${{ github.event.release.name }}" >> message.txt +# - run: echo "" >> message.txt +# - run: echo "${{ github.event.release.body }}" >> message.txt +# - run: echo "${{ github.event.release.html_url }}" >> message.txt - # send message, @plebbit telegram chat id is -1001665335693 - - name: "telegram notification" - uses: appleboy/telegram-action@master - with: - to: -1001665335693 - token: ${{ secrets.TELEGRAM_TOKEN }} - format: html - message_file: message.txt +# # send message, @plebbit telegram chat id is -1001665335693 +# - name: "telegram notification" +# uses: appleboy/telegram-action@master +# with: +# to: -1001665335693 +# token: ${{ secrets.TELEGRAM_TOKEN }} +# format: html +# message_file: message.txt - issue: - if: ${{ github.event_name == 'issues' }} - runs-on: ubuntu-latest - steps: - # - name: debug - # env: - # DEBUG: ${{ toJSON(github) }} - # run: echo "$DEBUG" +# issue: +# if: ${{ github.event_name == 'issues' }} +# runs-on: ubuntu-latest +# steps: +# # - name: debug +# # env: +# # DEBUG: ${{ toJSON(github) }} +# # run: echo "$DEBUG" - # write message to file - - run: echo "${{ github.event.issue.title }}" >> message.txt - - run: echo "" >> message.txt - - run: echo "by ${{ github.event.issue.user.login }}" >> message.txt - - run: echo "${{ github.event.issue.html_url }}" >> message.txt +# # write message to file +# - run: echo "${{ github.event.issue.title }}" >> message.txt +# - run: echo "" >> message.txt +# - run: echo "by ${{ github.event.issue.user.login }}" >> message.txt +# - run: echo "${{ github.event.issue.html_url }}" >> message.txt - # send message, @plebbit telegram chat id is -1001665335693 - - name: "telegram notification" - uses: appleboy/telegram-action@master - with: - to: -1001665335693 - token: ${{ secrets.TELEGRAM_TOKEN }} - format: html - message_file: message.txt +# # send message, @plebbit telegram chat id is -1001665335693 +# - name: "telegram notification" +# uses: appleboy/telegram-action@master +# with: +# to: -1001665335693 +# token: ${{ secrets.TELEGRAM_TOKEN }} +# format: html +# message_file: message.txt From f03671f585b49c5e28ba093ec3525a0fa0972baf Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 20 Feb 2024 13:00:48 +0100 Subject: [PATCH 03/11] style(submit): remove border from iframe link preview --- src/views/submit/submit.module.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/submit/submit.module.css b/src/views/submit/submit.module.css index 6f7eaedf..f4c38e39 100644 --- a/src/views/submit/submit.module.css +++ b/src/views/submit/submit.module.css @@ -185,6 +185,7 @@ h1 { max-width: 100%; max-height: 300px; box-sizing: border-box; + border: none; } @media (max-width: 768px) { From c2de6acc9d5bddf53991deafe35a67a63be1abf3 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 20 Feb 2024 18:03:38 +0100 Subject: [PATCH 04/11] fix last visit dotted border --- src/components/post/post.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/post/post.tsx b/src/components/post/post.tsx index e112a5d2..94fbc744 100644 --- a/src/components/post/post.tsx +++ b/src/components/post/post.tsx @@ -199,13 +199,13 @@ const Post = ({ index, post = {} }: PostProps) => {
-

+

{isInPostView && link ? ( - + {postTitle ?? '-'} ) : ( - + {postTitle ?? '-'} )} From 9d2c01d12fff752422581988a05d779a76719c86 Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Tue, 20 Feb 2024 22:32:22 +0100 Subject: [PATCH 05/11] fix(challenge modal): special characters couldn't get rendered in post content preview --- src/components/challenge-modal/challenge-modal.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/challenge-modal/challenge-modal.tsx b/src/components/challenge-modal/challenge-modal.tsx index 2f0f9fee..8a931e91 100644 --- a/src/components/challenge-modal/challenge-modal.tsx +++ b/src/components/challenge-modal/challenge-modal.tsx @@ -58,7 +58,9 @@ const Challenge = ({ challenge, closeModal }: ChallengeProps) => {

{t('challenge_from', { subplebbit: shortSubplebbitAddress || subplebbitAddress })}
{publicationType === 'vote' && votePreview + ' '} - {parentCid ? t('challenge_for_reply', { parentAddress, publicationContent }) : t('challenge_for_post', { publicationContent })} + {parentCid + ? t('challenge_for_reply', { parentAddress, publicationContent, interpolation: { escapeValue: false } }) + : t('challenge_for_post', { publicationContent, interpolation: { escapeValue: false } })}
{isTextChallenge &&
{challenges[currentChallengeIndex]?.challenge}
} From 11cc1a430fc98429a2a2e52b4e1ed339f317f26c Mon Sep 17 00:00:00 2001 From: "plebeius.eth" Date: Wed, 21 Feb 2024 22:07:19 +0100 Subject: [PATCH 06/11] feat: add author edit reason, spoiler --- src/components/edit-form/edit-form.tsx | 134 +++++++++++++----- .../post/comment-tools/comment-tools.tsx | 32 +++-- .../comment-tools/edit-menu/edit-menu.tsx | 24 +--- src/components/post/expando/expando.tsx | 17 ++- src/components/post/post.tsx | 3 +- .../reply-form/reply-form.module.css | 14 ++ src/components/reply/reply.tsx | 1 + .../address-settings/address-settings.tsx | 2 +- src/views/submit/submit.tsx | 4 +- 9 files changed, 158 insertions(+), 73 deletions(-) diff --git a/src/components/edit-form/edit-form.tsx b/src/components/edit-form/edit-form.tsx index 7ffa2f40..f3784bcc 100644 --- a/src/components/edit-form/edit-form.tsx +++ b/src/components/edit-form/edit-form.tsx @@ -1,39 +1,84 @@ import { useEffect, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { PublishCommentEditOptions, useComment, usePublishCommentEdit } from '@plebbit/plebbit-react-hooks'; +import { PublishCommentEditOptions, usePublishCommentEdit } from '@plebbit/plebbit-react-hooks'; import { FormattingHelpTable } from '../reply-form'; import styles from '../reply-form/reply-form.module.css'; import { alertChallengeVerificationFailed } from '../../lib/utils/challenge-utils'; import challengesStore from '../../hooks/use-challenges'; +import { create } from 'zustand'; + +type EditStoreState = { + commentCid: string | undefined; + content: string | undefined; + reason: string | undefined; + spoiler: boolean | undefined; + subplebbitAddress: string | undefined; + publishCommentEditOptions: PublishCommentEditOptions; + setEditStore: (data: Partial) => void; + resetEditStore: () => void; +}; const { addChallenge } = challengesStore.getState(); +const useEditStore = create((set) => ({ + commentCid: undefined, + content: undefined, + reason: undefined, + spoiler: undefined, + subplebbitAddress: undefined, + publishCommentEditOptions: {}, + setEditStore: ({ commentCid, content, reason, spoiler, subplebbitAddress }) => + set((state) => { + const nextState = { ...state }; + if (commentCid !== undefined) nextState.commentCid = commentCid; + if (content !== undefined) nextState.content = content; + if (reason !== undefined) nextState.reason = reason; + if (spoiler !== undefined) nextState.spoiler = spoiler; + if (subplebbitAddress !== undefined) nextState.subplebbitAddress = subplebbitAddress; + + nextState.publishCommentEditOptions = { + ...nextState, + onChallenge: (...args: any) => addChallenge(args), + onChallengeVerification: alertChallengeVerificationFailed, + onError: (error: Error) => { + console.error(error); + let errorMessage = error.message; + alert(errorMessage); + }, + }; + return nextState; + }), + resetEditStore: () => + set({ commentCid: undefined, content: undefined, reason: undefined, spoiler: undefined, subplebbitAddress: undefined, publishCommentEditOptions: {} }), +})); + interface EditFormProps { commentCid: string; content: string; hideEditForm?: () => void; + spoiler?: boolean; subplebbitAddress: string; } -const EditForm = ({ commentCid, content, hideEditForm, subplebbitAddress }: EditFormProps) => { +const EditForm = ({ commentCid, content, hideEditForm, spoiler = false, subplebbitAddress }: EditFormProps) => { const { t } = useTranslation(); - const textRef = useRef(null); + const [showOptions, setShowOptions] = useState(false); const [showFormattingHelp, setShowFormattingHelp] = useState(false); - const [text, setText] = useState(content); + const spoilerClass = showOptions ? styles.spoilerVisible : styles.spoilerHidden; + + const textRef = useRef(null); + + const { setEditStore, resetEditStore, publishCommentEditOptions } = useEditStore(); - const comment = useComment({ commentCid }); + // initial values + useEffect(() => { + setEditStore({ commentCid, content, spoiler, subplebbitAddress }); + return () => { + // cleanup + resetEditStore(); + }; + }, [commentCid, content, spoiler, subplebbitAddress]); - const publishCommentEditOptions: PublishCommentEditOptions = { - commentCid, - content: text, - subplebbitAddress, - onChallenge: (...args: any) => addChallenge([...args, comment]), - onChallengeVerification: alertChallengeVerificationFailed, - onError: (error: Error) => { - console.warn(error); - alert(error.message); - }, - }; const { publishCommentEdit } = usePublishCommentEdit(publishCommentEditOptions); useEffect(() => { @@ -45,29 +90,50 @@ const EditForm = ({ commentCid, content, hideEditForm, subplebbitAddress }: Edit return (
-