Browse Source

remove redundant alt client tag

imwald
Silberengel 3 weeks ago
parent
commit
1abd3d51b6
  1. 3
      src/components/PostEditor/PostTextarea/Preview.tsx
  2. 12
      src/lib/draft-event.ts

3
src/components/PostEditor/PostTextarea/Preview.tsx

@ -2,7 +2,6 @@ import ClientTag from '@/components/ClientTag'
import { Card } from '@/components/ui/card' import { Card } from '@/components/ui/card'
import { ExtendedKind, POLL_TYPE } from '@/constants' import { ExtendedKind, POLL_TYPE } from '@/constants'
import { import {
buildAltTag,
buildClientTag, buildClientTag,
stripImwaldAttributionTags, stripImwaldAttributionTags,
transformCustomEmojisInContent transformCustomEmojisInContent
@ -164,7 +163,7 @@ export default function Preview({
} }
const stripped = stripImwaldAttributionTags(tags) const stripped = stripImwaldAttributionTags(tags)
if (addClientTag) { if (addClientTag) {
stripped.push(buildClientTag(), buildAltTag()) stripped.push(buildClientTag())
} }
return stripped return stripped
}, [emojiTags, highlightTags, pollTags, mediaImetaTags, articleMetadata, kind, extraPreviewTags, addClientTag]) }, [emojiTags, highlightTags, pollTags, mediaImetaTags, articleMetadata, kind, extraPreviewTags, addClientTag])

12
src/lib/draft-event.ts

@ -1405,12 +1405,8 @@ export function buildClientTag(handlerPubkey?: string, handlerIdentifier?: strin
return ['client', 'imwald'] return ['client', 'imwald']
} }
/** Canonical `alt` we attach for Imwald / jumble.imwald.eu publishing attribution (NIP-31). */ /** Canonical `alt` text used in legacy Jumble/Imwald attribution tags (kept for stripping old events). */
export const IMWALD_ATTRIBUTION_ALT_TEXT = 'This event was published by https://jumble.imwald.eu.' const IMWALD_ATTRIBUTION_ALT_TEXT = 'This event was published by https://jumble.imwald.eu.'
export function buildAltTag(): string[] {
return ['alt', IMWALD_ATTRIBUTION_ALT_TEXT]
}
/** /**
* True for `alt` tags that are *our* app attribution (current or legacy Jumble/Imwald wording). * True for `alt` tags that are *our* app attribution (current or legacy Jumble/Imwald wording).
@ -1445,7 +1441,7 @@ export function stripImwaldAttributionTags(tags: string[][]): string[][] {
/** /**
* Before sign/publish: strip all `client` tags and Imwald/Jumble attribution `alt` tags, then * Before sign/publish: strip all `client` tags and Imwald/Jumble attribution `alt` tags, then
* append exactly one {@link buildClientTag} + {@link buildAltTag} when `addClientTag !== false`. * append exactly one {@link buildClientTag} when `addClientTag !== false`.
*/ */
export function applyImwaldAttributionTags( export function applyImwaldAttributionTags(
draftEvent: TDraftEvent, draftEvent: TDraftEvent,
@ -1456,7 +1452,7 @@ export function applyImwaldAttributionTags(
const sanitizedTags = stripImwaldAttributionTags(existingTags) const sanitizedTags = stripImwaldAttributionTags(existingTags)
const shouldAdd = options?.addClientTag !== false const shouldAdd = options?.addClientTag !== false
if (shouldAdd) { if (shouldAdd) {
draft.tags = [...sanitizedTags, buildClientTag(), buildAltTag()] draft.tags = [...sanitizedTags, buildClientTag()]
} else { } else {
draft.tags = [...sanitizedTags] draft.tags = [...sanitizedTags]
} }

Loading…
Cancel
Save