diff --git a/packages/commonwealth/client/scripts/views/pages/discussions/DiscussionsPage.tsx b/packages/commonwealth/client/scripts/views/pages/discussions/DiscussionsPage.tsx index 7979c479939..ca8328a0a0b 100644 --- a/packages/commonwealth/client/scripts/views/pages/discussions/DiscussionsPage.tsx +++ b/packages/commonwealth/client/scripts/views/pages/discussions/DiscussionsPage.tsx @@ -293,7 +293,7 @@ const DiscussionsPage = ({ topicName }: DiscussionsPageProps) => { ? !disabledCommentPermissionTooltipText : !disabledActionsTooltipText } - onEditStart={() => navigate(`${discussionLink}`)} + onEditStart={() => navigate(`${discussionLink}?isEdit=true`)} onStageTagClick={() => { navigate(`/discussions?stage=${thread.stage}`); }} diff --git a/packages/commonwealth/client/scripts/views/pages/view_thread/ViewThreadPage.tsx b/packages/commonwealth/client/scripts/views/pages/view_thread/ViewThreadPage.tsx index 9af526fe0ec..0b49f9d1ed5 100644 --- a/packages/commonwealth/client/scripts/views/pages/view_thread/ViewThreadPage.tsx +++ b/packages/commonwealth/client/scripts/views/pages/view_thread/ViewThreadPage.tsx @@ -14,6 +14,7 @@ import { useCommonNavigate } from 'navigation/helpers'; import 'pages/view_thread/index.scss'; import React, { useEffect, useRef, useState } from 'react'; import { Helmet } from 'react-helmet-async'; +import { useSearchParams } from 'react-router-dom'; import app from 'state'; import { useFetchCommentsQuery } from 'state/api/comments'; import useGetContentByUrlQuery from 'state/api/general/getContentByUrl'; @@ -69,12 +70,11 @@ import { SnapshotCreationCard } from './snapshot_creation_card'; type ViewThreadPageProps = { identifier: string; }; - const ViewThreadPage = ({ identifier }: ViewThreadPageProps) => { const threadId = identifier.split('-')[0]; - + const [searchParams] = useSearchParams(); + const isEdit = searchParams.get('isEdit') ?? undefined; const navigate = useCommonNavigate(); - const [isEditingBody, setIsEditingBody] = useState(false); const [isGloballyEditing, setIsGloballyEditing] = useState(false); const [savedEdits, setSavedEdits] = useState(''); @@ -151,6 +151,18 @@ const ViewThreadPage = ({ identifier }: ViewThreadPageProps) => { thread?.topic?.id, ); + useEffect(() => { + if ( + isEdit === 'true' && + thread && + (isAdmin || Permissions.isThreadAuthor(thread)) + ) { + setShouldRestoreEdits(true); + setIsGloballyEditing(true); + setIsEditingBody(true); + } + }, [isEdit, thread, isAdmin]); + const { data: comments = [], error: fetchCommentsError } = useFetchCommentsQuery({ communityId,