feat: adjust hide username emojis pref to only hide in timeline (#1631)
This commit is contained in:
parent
7dfe91bb9d
commit
a1b2da3d5e
9 changed files with 28 additions and 20 deletions
|
@ -8,7 +8,7 @@ import { emojiRegEx, getEmojiAttributes } from '../config/emojis'
|
|||
|
||||
export interface ContentParseOptions {
|
||||
emojis?: Record<string, mastodon.v1.CustomEmoji>
|
||||
showEmojis?: boolean
|
||||
hideEmojis?: boolean
|
||||
mentions?: mastodon.v1.StatusMention[]
|
||||
markdown?: boolean
|
||||
replaceUnicodeEmoji?: boolean
|
||||
|
@ -82,7 +82,7 @@ export function parseMastodonHTML(
|
|||
replaceUnicodeEmoji = true,
|
||||
convertMentionLink = false,
|
||||
collapseMentionLink = false,
|
||||
showEmojis = true,
|
||||
hideEmojis = false,
|
||||
mentions,
|
||||
status,
|
||||
inReplyToStatus,
|
||||
|
@ -110,16 +110,16 @@ export function parseMastodonHTML(
|
|||
...options.astTransforms || [],
|
||||
]
|
||||
|
||||
if (showEmojis) {
|
||||
if (hideEmojis) {
|
||||
transforms.push(removeUnicodeEmoji)
|
||||
transforms.push(removeCustomEmoji(options.emojis ?? {}))
|
||||
}
|
||||
else {
|
||||
if (replaceUnicodeEmoji)
|
||||
transforms.push(transformUnicodeEmoji)
|
||||
|
||||
transforms.push(replaceCustomEmoji(options.emojis ?? {}))
|
||||
}
|
||||
else {
|
||||
transforms.push(removeUnicodeEmoji)
|
||||
transforms.push(removeCustomEmoji(options.emojis ?? {}))
|
||||
}
|
||||
|
||||
if (markdown)
|
||||
transforms.push(transformMarkdown)
|
||||
|
|
|
@ -30,8 +30,8 @@ export function contentToVNode(
|
|||
const textContents = getTexualAstComponents(tree.children)
|
||||
|
||||
// if the username only contains emojis, we should probably show the emojis anyway to avoid a blank name
|
||||
if (!options?.showEmojis && textContents.length === 0)
|
||||
tree = parseMastodonHTML(content, { ...options, showEmojis: true })
|
||||
if (options?.hideEmojis && textContents.length === 0)
|
||||
tree = parseMastodonHTML(content, { ...options, hideEmojis: false })
|
||||
|
||||
return h(Fragment, (tree.children as Node[] || []).map(n => treeToVNode(n)))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue