diff --git a/src/components/PostEditor/PostContent.tsx b/src/components/PostEditor/PostContent.tsx index 3d956b1c..d2e73ab5 100644 --- a/src/components/PostEditor/PostContent.tsx +++ b/src/components/PostEditor/PostContent.tsx @@ -4,7 +4,6 @@ import { ScrollArea } from '@/components/ui/scroll-area' import { Input } from '@/components/ui/input' import { Textarea } from '@/components/ui/textarea' import { Label } from '@/components/ui/label' -import { Checkbox } from '@/components/ui/checkbox' import { Skeleton } from '@/components/ui/skeleton' import { DropdownMenu, @@ -31,12 +30,10 @@ import { createCitationInternalDraftEvent, createCitationExternalDraftEvent, createCitationHardcopyDraftEvent, - createCitationPromptDraftEvent, - createGitReleaseDraftEvent + createCitationPromptDraftEvent } from '@/lib/draft-event' import { ExtendedKind } from '@/constants' -import { parseRepoOwnerPubkeyInput } from '@/lib/git-republic-event' -import { cn, isTouchDevice } from '@/lib/utils' +import { isTouchDevice } from '@/lib/utils' import { useNostr } from '@/providers/NostrProvider' import { useFeed } from '@/providers/FeedProvider' import { useReply } from '@/providers/ReplyProvider' @@ -243,15 +240,6 @@ export default function PostContent({ const [citationGeohash, setCitationGeohash] = useState('') const [citationVersion, setCitationVersion] = useState('') const [citationSummary, setCitationSummary] = useState('') - const [isGitRelease, setIsGitRelease] = useState(false) - const [releaseRepoOwnerInput, setReleaseRepoOwnerInput] = useState('') - const [releaseRepoId, setReleaseRepoId] = useState('') - const [releaseTagName, setReleaseTagName] = useState('') - const [releaseTagHash, setReleaseTagHash] = useState('') - const [releaseTitle, setReleaseTitle] = useState('') - const [releaseDownloadUrl, setReleaseDownloadUrl] = useState('') - const [releaseDraft, setReleaseDraft] = useState(false) - const [releasePrerelease, setReleasePrerelease] = useState(false) const [hasPrivateRelaysAvailable, setHasPrivateRelaysAvailable] = useState(false) const [showMediaKindDialog, setShowMediaKindDialog] = useState(false) @@ -265,16 +253,6 @@ export default function PostContent({ } }, [mediaNoteKind, mediaImetaTags]) const isFirstRender = useRef(true) - const releaseFieldsOk = useMemo(() => { - if (!isGitRelease) return true - const owner = parseRepoOwnerPubkeyInput(releaseRepoOwnerInput) - return ( - !!owner && - !!releaseRepoId.trim() && - !!releaseTagName.trim() && - /^[0-9a-f]{40}$/i.test(releaseTagHash.trim()) - ) - }, [isGitRelease, releaseRepoOwnerInput, releaseRepoId, releaseTagName, releaseTagHash]) const canPost = useMemo(() => { const isArticle = isLongFormArticle || isWikiArticle || isWikiArticleMarkdown || isPublicationContent @@ -282,15 +260,14 @@ export default function PostContent({ !!pubkey && !posting && !uploadProgresses.length && - // For media notes, text is optional - just need media; Git releases use the editor as release notes (optional) - ((mediaNoteKind !== null && mediaUrl) || !!text || isGitRelease) && + // For media notes, text is optional - just need media + ((mediaNoteKind !== null && mediaUrl) || !!text) && (!isPoll || pollCreateData.options.filter((option) => !!option.trim()).length >= 2) && (!isPublicMessage || extractedMentions.length > 0 || parentEvent?.kind === ExtendedKind.PUBLIC_MESSAGE) && (!isProtectedEvent || additionalRelayUrls.length > 0) && (!isHighlight || highlightData.sourceValue.trim() !== '') && // For articles, dTag is mandatory (!isArticle || !!articleDTag.trim()) && - (!isGitRelease || releaseFieldsOk) && // For citations, required fields must be filled (!isCitationInternal || !!citationInternalCTag.trim()) && (!isCitationExternal || (!!citationExternalUrl.trim() && !!citationAccessedOn.trim())) && @@ -320,8 +297,6 @@ export default function PostContent({ isWikiArticleMarkdown, isPublicationContent, articleDTag, - isGitRelease, - releaseFieldsOk, isCitationInternal, citationInternalCTag, isCitationExternal, @@ -413,8 +388,6 @@ export default function PostContent({ return ExtendedKind.WIKI_ARTICLE_MARKDOWN } else if (isPublicationContent) { return ExtendedKind.PUBLICATION_CONTENT - } else if (isGitRelease) { - return ExtendedKind.GIT_RELEASE } else if (isCitationInternal) { return ExtendedKind.CITATION_INTERNAL } else if (isCitationExternal) { @@ -439,7 +412,6 @@ export default function PostContent({ isWikiArticle, isWikiArticleMarkdown, isPublicationContent, - isGitRelease, isCitationInternal, isCitationExternal, isCitationHardcopy, @@ -675,23 +647,6 @@ export default function PostContent({ }) } - if (isGitRelease) { - const ownerHex = parseRepoOwnerPubkeyInput(releaseRepoOwnerInput) - if (!ownerHex) { - throw new Error(t('Invalid repository owner pubkey')) - } - return createGitReleaseDraftEvent(cleanedText, { - repoOwnerPubkey: ownerHex, - repoId: releaseRepoId.trim(), - tagName: releaseTagName.trim(), - tagHash: releaseTagHash.trim().toLowerCase(), - title: releaseTitle.trim() || undefined, - downloadUrl: releaseDownloadUrl.trim() || undefined, - isDraft: releaseDraft, - isPrerelease: releasePrerelease - }) - } - // Citations if (isCitationInternal) { return createCitationInternalDraftEvent(cleanedText, { @@ -827,15 +782,6 @@ export default function PostContent({ isWikiArticle, isWikiArticleMarkdown, isPublicationContent, - isGitRelease, - releaseRepoOwnerInput, - releaseRepoId, - releaseTagName, - releaseTagHash, - releaseTitle, - releaseDownloadUrl, - releaseDraft, - releasePrerelease, isCitationInternal, isCitationExternal, isCitationHardcopy, @@ -864,9 +810,6 @@ export default function PostContent({ if (isArticle && !articleDTag.trim()) { throw new Error(t('D-Tag is required for articles')) } - if (isGitRelease && !releaseFieldsOk) { - throw new Error(t('Fill repository release fields')) - } if (!pubkey) { return JSON.stringify({ error: 'Not logged in' }, null, 2) @@ -889,8 +832,6 @@ export default function PostContent({ isWikiArticleMarkdown, isPublicationContent, articleDTag, - isGitRelease, - releaseFieldsOk, createDraftEvent, t ]) @@ -1059,7 +1000,6 @@ export default function PostContent({ // When enabling poll mode, clear other modes setIsPublicMessage(false) setIsHighlight(false) - setIsGitRelease(false) setIsCitationInternal(false) setIsCitationExternal(false) setIsCitationHardcopy(false) @@ -1075,7 +1015,6 @@ export default function PostContent({ // When enabling public message mode, clear other modes setIsPoll(false) setIsHighlight(false) - setIsGitRelease(false) setIsCitationInternal(false) setIsCitationExternal(false) setIsCitationHardcopy(false) @@ -1091,7 +1030,6 @@ export default function PostContent({ // When enabling highlight mode, clear other modes and set client tag to true setIsPoll(false) setIsPublicMessage(false) - setIsGitRelease(false) setIsCitationInternal(false) setIsCitationExternal(false) setIsCitationHardcopy(false) @@ -1483,7 +1421,6 @@ export default function PostContent({ setIsCitationExternal(false) setIsCitationHardcopy(false) setIsCitationPrompt(false) - setIsGitRelease(false) // Clear uploaded file from map and picture accumulation ref uploadedMediaFileMap.current.clear() @@ -1503,7 +1440,6 @@ export default function PostContent({ setIsPublicMessage(false) setIsHighlight(false) setMediaNoteKind(null) - setIsGitRelease(false) setIsCitationInternal(false) setIsCitationExternal(false) setIsCitationHardcopy(false) @@ -1534,7 +1470,6 @@ export default function PostContent({ const handleCitationToggle = (type: 'internal' | 'external' | 'hardcopy' | 'prompt') => { if (parentEvent) return // Can't create citations as replies - setIsGitRelease(false) setIsCitationInternal(type === 'internal') setIsCitationExternal(type === 'external') setIsCitationHardcopy(type === 'hardcopy') @@ -1556,24 +1491,6 @@ export default function PostContent({ } } - const handleGitReleaseFromMenu = () => { - if (parentEvent) return - - setIsGitRelease(true) - setIsCitationInternal(false) - setIsCitationExternal(false) - setIsCitationHardcopy(false) - setIsCitationPrompt(false) - setIsPoll(false) - setIsPublicMessage(false) - setIsHighlight(false) - setMediaNoteKind(null) - setIsLongFormArticle(false) - setIsWikiArticle(false) - setIsWikiArticleMarkdown(false) - setIsPublicationContent(false) - } - const handleClear = () => { // Clear the post editor cache postEditorCache.clearPostCache({ kind: getDeterminedKind, defaultContent, parentEvent }) @@ -1599,15 +1516,6 @@ export default function PostContent({ setIsCitationExternal(false) setIsCitationHardcopy(false) setIsCitationPrompt(false) - setIsGitRelease(false) - setReleaseRepoOwnerInput('') - setReleaseRepoId('') - setReleaseTagName('') - setReleaseTagHash('') - setReleaseTitle('') - setReleaseDownloadUrl('') - setReleaseDraft(false) - setReleasePrerelease(false) // Clear citation fields setCitationInternalCTag('') setCitationInternalRelayHint('') @@ -1688,8 +1596,6 @@ export default function PostContent({ return t('New Hardcopy Citation') } else if (determinedKind === ExtendedKind.CITATION_PROMPT) { return t('New Prompt Citation') - } else if (determinedKind === ExtendedKind.GIT_RELEASE) { - return t('New Repository Release') } else { return t('New Note') } @@ -1787,23 +1693,18 @@ export default function PostContent({ {(isCitationInternal || isCitationExternal || isCitationHardcopy || - isCitationPrompt || - isGitRelease) && ( + isCitationPrompt) && (
- {t('Release notes use the editor below (optional).')} -
-