Skip to content

Commit 447cb04

Browse files
committed
perf: rewrite emotes component temporary remove popovers for now
1 parent f191fae commit 447cb04

1 file changed

Lines changed: 8 additions & 30 deletions

File tree

app/components/ChannelEmotes.vue

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,22 @@ const { data: emotes } = await useLazyFetch("/api/channel-emotes", {
1212
});
1313
1414
const parsedParts = computed(() => {
15-
const words = props.text.split(" ");
15+
const tokens = props.text.split(" ");
1616
17-
if (!emotes.value) return words;
17+
if (!emotes.value) return tokens.map(token => ({ token, url: null as string | null }));
1818
19-
const parts: (string | VNode)[] = [];
20-
21-
for (const word of words) {
22-
const emoteUrl = emotes.value[word];
23-
parts.push(
24-
emoteUrl ? h("img", {
25-
class: "h-8 -my-2",
26-
src: emoteUrl,
27-
alt: word,
28-
loading: "lazy",
29-
decoding: "async"
30-
}) : word
31-
);
32-
}
33-
34-
return parts;
19+
return tokens.map(token => ({
20+
token,
21+
url: emotes.value![token] ?? null
22+
}));
3523
});
3624
</script>
3725

3826
<template>
3927
<span class="channel-emotes max-h-6 relative">
4028
<template v-for="(part, index) in parsedParts" :key="index">
41-
<template v-if="typeof part === 'string'">
42-
{{ part }}
43-
</template>
44-
<UPopover v-else-if="popover" mode="hover" :content="{ side: 'top' }" arrow>
45-
<UButton variant="link" class="p-0 align-middle inline-flex">
46-
<component :is="part" />
47-
</UButton>
48-
<template #content>
49-
{{ part.props!.alt }}
50-
</template>
51-
</UPopover>
52-
<component :is="part" v-else class="inline-block align-middle" :title="part.props!.alt" />
29+
<template v-if="!part.url">{{ part.token }}</template>
30+
<img v-else class="inline-block align-middle h-8 -my-2" :src="part.url" :alt="part.token" loading="lazy" decoding="async" :title="part.token">
5331
<template v-if="index < parsedParts.length - 1">{{ ' ' }}</template>
5432
</template>
5533
</span>

0 commit comments

Comments
 (0)