Frontend: Display missing emoji as raw text
This commit is contained in:
parent
c3e7791b3e
commit
10bddd886e
|
@ -1,6 +1,6 @@
|
||||||
|
import type { VNode } from "vue";
|
||||||
import { defineComponent, h } from "vue";
|
import { defineComponent, h } from "vue";
|
||||||
import * as mfm from "mfm-js";
|
import * as mfm from "mfm-js";
|
||||||
import type { VNode } from "vue";
|
|
||||||
import MkUrl from "@/components/global/MkUrl.vue";
|
import MkUrl from "@/components/global/MkUrl.vue";
|
||||||
import MkLink from "@/components/MkLink.vue";
|
import MkLink from "@/components/MkLink.vue";
|
||||||
import MagMention from "@/components/MagMention.vue";
|
import MagMention from "@/components/MagMention.vue";
|
||||||
|
@ -11,12 +11,11 @@ import MkSparkle from "@/components/MkSparkle.vue";
|
||||||
import MkA from "@/components/global/MkA.vue";
|
import MkA from "@/components/global/MkA.vue";
|
||||||
import { host } from "@/config";
|
import { host } from "@/config";
|
||||||
import { reducedMotion } from "@/scripts/reduced-motion";
|
import { reducedMotion } from "@/scripts/reduced-motion";
|
||||||
import { defaultStore } from "@/store";
|
|
||||||
import MagEmoji from "@/components/global/MagEmoji.vue";
|
import MagEmoji from "@/components/global/MagEmoji.vue";
|
||||||
import {
|
import {
|
||||||
magConvertReaction,
|
magConvertReaction,
|
||||||
|
magIsMissingEmoji,
|
||||||
magReactionEquals,
|
magReactionEquals,
|
||||||
magReactionToLegacy,
|
|
||||||
magTransProperty,
|
magTransProperty,
|
||||||
} from "@/scripts-mag/mag-util";
|
} from "@/scripts-mag/mag-util";
|
||||||
|
|
||||||
|
@ -542,11 +541,9 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
case "emojiCode": {
|
case "emojiCode": {
|
||||||
return [
|
const shortcode = `:${token.props.name}:`;
|
||||||
h(MagEmoji, {
|
const emoji = magConvertReaction(
|
||||||
key: Math.random(),
|
shortcode,
|
||||||
emoji: magConvertReaction(
|
|
||||||
`:${token.props.name}:`,
|
|
||||||
(name, host) =>
|
(name, host) =>
|
||||||
this.customEmojis.find((e) =>
|
this.customEmojis.find((e) =>
|
||||||
magReactionEquals(
|
magReactionEquals(
|
||||||
|
@ -560,7 +557,16 @@ export default defineComponent({
|
||||||
{ name, host, url: null! }
|
{ name, host, url: null! }
|
||||||
)
|
)
|
||||||
)?.url ?? null
|
)?.url ?? null
|
||||||
),
|
);
|
||||||
|
|
||||||
|
if (magIsMissingEmoji(emoji)) {
|
||||||
|
return [shortcode];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
h(MagEmoji, {
|
||||||
|
key: Math.random(),
|
||||||
|
emoji,
|
||||||
normal: this.plain,
|
normal: this.plain,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
|
@ -226,6 +226,10 @@ export function magIsCustomEmoji(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function magIsMissingEmoji(emoji: types.Reaction): boolean {
|
||||||
|
return magIsCustomEmoji(emoji) && !emoji["url"];
|
||||||
|
}
|
||||||
|
|
||||||
export function magIsUnicodeEmoji(
|
export function magIsUnicodeEmoji(
|
||||||
emoji: types.Reaction
|
emoji: types.Reaction
|
||||||
): emoji is types.ReactionUnicode {
|
): emoji is types.ReactionUnicode {
|
||||||
|
|
Loading…
Reference in New Issue