perf(client): do not render custom emojis in user names

#9778
This commit is contained in:
syuilo 2023-02-08 17:48:02 +09:00
parent 2e565cac2c
commit 650187deaf
32 changed files with 42 additions and 71 deletions

View file

@ -150,17 +150,9 @@ export class CustomEmojiService {
if (note.renote) {
emojis = emojis.concat(note.renote.emojis
.map(e => this.parseEmojiStr(e, note.renote!.userHost)));
if (note.renote.user) {
emojis = emojis.concat(note.renote.user.emojis
.map(e => this.parseEmojiStr(e, note.renote!.userHost)));
}
}
const customReactions = Object.keys(note.reactions).map(x => this.reactionService.decodeReaction(x)).filter(x => x.name != null) as typeof emojis;
emojis = emojis.concat(customReactions);
if (note.user) {
emojis = emojis.concat(note.user.emojis
.map(e => this.parseEmojiStr(e, note.userHost)));
}
}
return emojis.filter(x => x.name != null && x.host != null) as { name: string; host: string; }[];
}

View file

@ -413,7 +413,6 @@ export class UserEntityService implements OnModuleInit {
faviconUrl: instance.faviconUrl,
themeColor: instance.themeColor,
} : undefined) : undefined,
emojis: this.customEmojiService.populateEmojis(user.emojis, user.host),
onlineStatus: this.getOnlineStatus(user),
// パフォーマンス上の理由でローカルユーザーのみ
badgeRoles: user.host == null ? this.roleService.getUserBadgeRoles(user.id).then(rs => rs.map(r => ({
@ -464,6 +463,7 @@ export class UserEntityService implements OnModuleInit {
isModerator: role.isModerator,
isAdministrator: role.isAdministrator,
}))),
emojis: this.customEmojiService.populateEmojis(user.emojis, user.host),
} : {}),
...(opts.detail && isMe ? {

View file

@ -4,7 +4,7 @@
<MkA v-user-preview="report.targetUserId" class="info" :to="`/user-info/${report.targetUserId}`">
<MkAvatar class="avatar" :user="report.targetUser" indicator/>
<div class="names">
<MkUserName class="name" :user="report.targetUser"/>
<span class="name _nowrap">{{ report.targetUser.name ?? report.targetUser.username }}</span>
<MkAcct class="acct" :user="report.targetUser" style="display: block;"/>
</div>
</MkA>

View file

@ -4,7 +4,7 @@
<li v-for="user in users" tabindex="-1" :class="$style.item" @click="complete(type, user)" @keydown="onKeydown">
<img :class="$style.avatar" :src="user.avatarUrl"/>
<span :class="$style.userName">
<MkUserName :key="user.id" :user="user"/>
<span :key="user.id" class="_nowrap">{{ user.name ?? user.username }}</span>
</span>
<span>@{{ acct(user) }}</span>
</li>

View file

@ -27,7 +27,7 @@
<span v-if="item.indicate" :class="$style.indicator"><i class="_indicatorCircle"></i></span>
</a>
<button v-else-if="item.type === 'user'" :tabindex="i" class="_button" :class="[$style.item, { [$style.active]: item.active }]" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<MkAvatar :user="item.user" :class="$style.avatar"/><MkUserName :user="item.user"/>
<MkAvatar :user="item.user" :class="$style.avatar"/><span class="_nowrap">{{ item.user.name ?? item.user.username }}</span>
<span v-if="item.indicate" :class="$style.indicator"><i class="_indicatorCircle"></i></span>
</button>
<span v-else-if="item.type === 'switch'" :tabindex="i" :class="$style.item" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">

View file

@ -17,7 +17,7 @@
<I18n :src="i18n.ts.renotedBy" tag="span" :class="$style.renoteText">
<template #user>
<MkA v-user-preview="note.userId" :class="$style.renoteUserName" :to="userPage(note.user)">
<MkUserName :user="note.user"/>
<span class="_nowrap">{{ note.user.name ?? note.user.username }}</span>
</MkA>
</template>
</I18n>
@ -108,7 +108,7 @@
<I18n :src="i18n.ts.userSaysSomething" tag="small">
<template #name>
<MkA v-user-preview="appearNote.userId" :to="userPage(appearNote.user)">
<MkUserName :user="appearNote.user"/>
<span class="_nowrap">{{ appearNote.user.name ?? appearNote.user.username }}</span>
</MkA>
</template>
</I18n>

View file

@ -16,7 +16,7 @@
<I18n :src="i18n.ts.renotedBy" tag="span">
<template #user>
<MkA v-user-preview="note.userId" class="name" :to="userPage(note.user)">
<MkUserName :user="note.user"/>
<span class="_nowrap">{{ note.user.name ?? note.user.username }}</span>
</MkA>
</template>
</I18n>
@ -39,7 +39,7 @@
<div class="body">
<div class="top">
<MkA v-user-preview="appearNote.user.id" class="name" :to="userPage(appearNote.user)">
<MkUserName :nowrap="false" :user="appearNote.user"/>
<span class="_nowrap">{{ appearNote.user.name ?? appearNote.user.username }}</span>
</MkA>
<span v-if="appearNote.user.isBot" class="is-bot">bot</span>
<div class="info">
@ -125,7 +125,7 @@
<I18n :src="i18n.ts.userSaysSomething" tag="small">
<template #name>
<MkA v-user-preview="appearNote.userId" class="name" :to="userPage(appearNote.user)">
<MkUserName :user="appearNote.user"/>
<span class="_nowrap">{{ appearNote.user.name ?? appearNote.user.username }}</span>
</MkA>
</template>
</I18n>

View file

@ -1,7 +1,7 @@
<template>
<header :class="$style.root">
<MkA v-once v-user-preview="note.user.id" :class="$style.name" :to="userPage(note.user)">
<MkUserName :user="note.user"/>
<span class="_nowrap">{{ note.user.name ?? note.user.username }}</span>
</MkA>
<div v-if="note.user.isBot" :class="$style.isBot">bot</div>
<div :class="$style.username"><MkAcct :user="note.user"/></div>

View file

@ -3,7 +3,7 @@
<MkAvatar :class="$style.avatar" :user="$i" link preview/>
<div :class="$style.main">
<div :class="$style.header">
<MkUserName :user="$i"/>
<span class="_nowrap">{{ $i.name ?? $i.username }}</span>
</div>
<div>
<div :class="$style.content">

View file

@ -31,7 +31,7 @@
<header :class="$style.header">
<span v-if="notification.type === 'pollEnded'">{{ i18n.ts._notification.pollEnded }}</span>
<span v-else-if="notification.type === 'achievementEarned'">{{ i18n.ts._notification.achievementEarned }}</span>
<MkA v-else-if="notification.user" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
<MkA v-else-if="notification.user" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><span class="_nowrap">{{ notification.user.name ?? notification.user.username }}</span></MkA>
<span v-else>{{ notification.header }}</span>
<MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/>
</header>

View file

@ -8,7 +8,7 @@
<div :class="$style.users">
<div v-for="u in users" :key="u.id" :class="$style.user">
<MkAvatar :class="$style.avatar" :user="u"/>
<MkUserName :user="u" :nowrap="true"/>
<span class="_nowrap">{{ u.name ?? u.username }}</span>
</div>
<div v-if="users.length > 10">+{{ count - 10 }}</div>
</div>

View file

@ -2,7 +2,7 @@
<div v-adaptive-bg :class="[$style.root, { yellow: user.isSilenced, red: user.isSuspended, gray: false }]">
<MkAvatar class="avatar" :user="user" indicator/>
<div class="body">
<span class="name"><MkUserName class="name" :user="user"/></span>
<span class="name _nowrap">{{ user.name ?? user.username }}</span>
<span class="sub"><span class="acct _monospace">@{{ acct(user) }}</span></span>
</div>
<MkMiniChart v-if="chartValues" class="chart" :src="chartValues"/>

View file

@ -3,8 +3,9 @@
<div class="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''"></div>
<MkAvatar class="avatar" :user="user" indicator/>
<div class="title">
<MkA class="name" :to="userPage(user)"><MkUserName :user="user" :nowrap="false"/></MkA>
<p class="username"><MkAcct :user="user"/></p>
<MkA class="name _nowrap" :to="userPage(user)"{{ user.name ?? user.username }}</mk-a>
<p class="username"><MkAcct :user="user"/></p>
</mka>
</div>
<span v-if="$i && $i.id !== user.id && user.isFollowed" class="followed">{{ $ts.followsYou }}</span>
<div class="description">

View file

@ -7,7 +7,7 @@
</div>
<MkAvatar class="avatar" :user="user" indicator/>
<div class="title">
<MkA class="name" :to="userPage(user)"><MkUserName :user="user" :nowrap="false"/></MkA>
<MkA class="name _nowrap" :to="userPage(user)">{{ user.name ?? user.username }}</MkA>
<p class="username"><MkAcct :user="user"/></p>
</div>
<div class="description">

View file

@ -27,7 +27,7 @@
<div v-for="user in users" :key="user.id" class="_button" :class="[$style.user, { [$style.selected]: selected && selected.id === user.id }]" @click="selected = user" @dblclick="ok()">
<MkAvatar :user="user" :class="$style.avatar" indicator/>
<div :class="$style.userBody">
<MkUserName :user="user" :class="$style.userName"/>
<span :class="$style.userName" class="_nowrap">{{ user.name ?? user.username }}</span>
<MkAcct :user="user" :class="$style.userAcct"/>
</div>
</div>
@ -41,7 +41,7 @@
<div v-for="user in recentUsers" :key="user.id" class="_button" :class="[$style.user, { [$style.selected]: selected && selected.id === user.id }]" @click="selected = user" @dblclick="ok()">
<MkAvatar :user="user" :class="$style.avatar" indicator/>
<div :class="$style.userBody">
<MkUserName :user="user" :class="$style.userName"/>
<span :class="$style.userName" class="_nowrap">{{ user.name ?? user.username }}</span>
<MkAcct :user="user" :class="$style.userAcct"/>
</div>
</div>

View file

@ -3,7 +3,7 @@
<div :class="$style.root">
<div v-for="u in users" :key="u.id" :class="$style.user">
<MkAvatar :class="$style.avatar" :user="u"/>
<MkUserName :class="$style.name" :user="u" :nowrap="true"/>
<span :class="$style.name" class="_nowrap">{{ u.name ?? u.username }}</span>
</div>
<div v-if="users.length < count" :class="$style.omitted">+{{ count - users.length }}</div>
</div>

View file

@ -1,5 +1,5 @@
<template>
<MfmCore :text="text" :plain="plain" :nowrap="nowrap" :author="author" :is-note="isNote" :class="[$style.root, { [$style.nowrap]: nowrap }]"/>
<MfmCore :text="text" :plain="plain" :nowrap="nowrap" :author="author" :is-note="isNote" :class="[$style.root, { '_nowrap': nowrap }]"/>
</template>
<script lang="ts" setup>
@ -160,12 +160,5 @@ const props = withDefaults(defineProps<{
<style lang="scss" module>
.root {
white-space: pre-wrap;
&.nowrap {
white-space: pre;
word-wrap: normal; // https://codeday.me/jp/qa/20190424/690106.html
overflow: hidden;
text-overflow: ellipsis;
}
}
</style>

View file

@ -9,7 +9,7 @@
<i v-else-if="metadata.icon" :class="[$style.titleIcon, metadata.icon]"></i>
<div :class="$style.title">
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true"/>
<span v-if="metadata.userName" class="_nowrap">{{ metadata.userName.name ?? metadata.userName.username }}</span>
<div v-else-if="metadata.title">{{ metadata.title }}</div>
<div v-if="!narrow && metadata.subtitle" :class="$style.subtitle">
{{ metadata.subtitle }}

View file

@ -1,15 +0,0 @@
<template>
<Mfm :text="user.name ?? user.username" :author="user" :plain="true" :nowrap="nowrap" :emoji-urls="user.emojis"/>
</template>
<script lang="ts" setup>
import { } from 'vue';
import * as misskey from 'misskey-js';
const props = withDefaults(defineProps<{
user: misskey.entities.User;
nowrap?: boolean;
}>(), {
nowrap: true,
});
</script>

View file

@ -6,7 +6,6 @@ import MkAcct from './global/MkAcct.vue';
import MkAvatar from './global/MkAvatar.vue';
import MkEmoji from './global/MkEmoji.vue';
import MkCustomEmoji from './global/MkCustomEmoji.vue';
import MkUserName from './global/MkUserName.vue';
import MkEllipsis from './global/MkEllipsis.vue';
import MkTime from './global/MkTime.vue';
import MkUrl from './global/MkUrl.vue';
@ -28,7 +27,6 @@ export default function(app: App) {
app.component('MkAvatar', MkAvatar);
app.component('MkEmoji', MkEmoji);
app.component('MkCustomEmoji', MkCustomEmoji);
app.component('MkUserName', MkUserName);
app.component('MkEllipsis', MkEllipsis);
app.component('MkTime', MkTime);
app.component('MkUrl', MkUrl);
@ -50,7 +48,6 @@ declare module '@vue/runtime-core' {
MkAvatar: typeof MkAvatar;
MkEmoji: typeof MkEmoji;
MkCustomEmoji: typeof MkCustomEmoji;
MkUserName: typeof MkUserName;
MkEllipsis: typeof MkEllipsis;
MkTime: typeof MkTime;
MkUrl: typeof MkUrl;

View file

@ -8,7 +8,7 @@
<Mfm :text="clip.description" :is-note="false" :i="$i"/>
</div>
<div class="user">
<MkAvatar :user="clip.user" class="avatar" indicator link preview/> <MkUserName :user="clip.user" :nowrap="false"/>
<MkAvatar :user="clip.user" class="avatar" indicator link preview/> <span class="_nowrap">{{ clip.user.name ?? clip.user.username }}</span>
</div>
</div>

View file

@ -15,7 +15,7 @@
<MkAvatar class="avatar" :user="req.follower" indicator link preview/>
<div class="body">
<div class="name">
<MkA v-user-preview="req.follower.id" class="name" :to="userPage(req.follower)"><MkUserName :user="req.follower"/></MkA>
<MkA v-user-preview="req.follower.id" class="name _nowrap" :to="userPage(req.follower)">{{ req.follower.name ?? req.follower.username }}</MkA>
<p class="acct">@{{ acct(req.follower) }}</p>
</div>
<div v-if="req.follower.description" class="description" :title="req.follower.description">

View file

@ -30,7 +30,7 @@
<div class="user">
<MkAvatar :user="post.user" class="avatar" link preview/>
<div class="name">
<MkUserName :user="post.user" style="display: block;"/>
<div class="_nowrap">{{ post.user.name ?? post.user.username }}</div>
<MkAcct :user="post.user"/>
</div>
<MkFollowButton v-if="!$i || $i.id != post.user.id" :user="post.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>

View file

@ -22,7 +22,7 @@
<MkTime :time="message.createdAt" class="time"/>
</header>
<header v-else>
<span class="name"><MkUserName :user="isMe(message) ? message.recipient : message.user"/></span>
<span class="name">{{ isMe(message) ? message.recipient.name : message.user.name }}</span>
<span class="username">@{{ acct(isMe(message) ? message.recipient : message.user) }}</span>
<MkTime :time="message.createdAt" class="time"/>
</header>

View file

@ -21,7 +21,7 @@
<div v-for="user in users" :key="user.id" class="user _panel">
<MkAvatar :user="user" class="avatar" indicator link preview/>
<div class="body">
<MkUserName :user="user" class="name"/>
<span class="name _nowrap">{{ user.name ?? user.username }}</span>
<MkAcct :user="user" class="acct"/>
</div>
<div class="action">

View file

@ -21,7 +21,7 @@
<b>{{ item.name }}</b>
<div v-if="item.description" class="description">{{ item.description }}</div>
<div class="user">
<MkAvatar :user="item.user" class="avatar" indicator link preview/> <MkUserName :user="item.user" :nowrap="false"/>
<MkAvatar :user="item.user" class="avatar" indicator link preview/> <span class="_nowrap">{{ item.user.name ?? item.user.username }}</span>
</div>
</MkA>
</div>

View file

@ -29,7 +29,7 @@
<div class="user">
<MkAvatar :user="page.user" class="avatar" link preview/>
<div class="name">
<MkUserName :user="page.user" style="display: block;"/>
<div class="_nowrap">{{ page.user.name ?? page.user.username }}</div>
<MkAcct :user="page.user"/>
</div>
<MkFollowButton v-if="!$i || $i.id != page.user.id" :user="page.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>

View file

@ -9,9 +9,7 @@
<MkAvatar :user="account" class="avatar"/>
</div>
<div class="body">
<div class="name">
<MkUserName :user="account"/>
</div>
<div class="name _nowrap">{{ account.name ?? account.username }}</div>
<div class="acct">
<MkAcct :user="account"/>
</div>

View file

@ -7,7 +7,7 @@
<div class="aeakzknw">
<MkAvatar class="avatar" :user="user" indicator link preview/>
<div class="body">
<span class="name"><MkUserName class="name" :user="user"/></span>
<span class="name _nowrap">{{ user.name ?? user.username }}</span>
<span class="sub"><span class="acct _monospace">@{{ acct(user) }}</span></span>
<span class="state">
<span v-if="suspended" class="suspended">Suspended</span>

View file

@ -14,7 +14,7 @@
<div ref="bannerEl" class="banner" :style="style"></div>
<div class="fade"></div>
<div class="title">
<MkUserName class="name" :user="user" :nowrap="true"/>
<span class="name _nowrap">{{ user.name ?? user.username }}</span>
<div class="bottom">
<span class="username"><MkAcct :user="user" :detail="true"/></span>
<span v-if="user.isAdmin" :title="i18n.ts.isAdmin" style="color: var(--badge);"><i class="ti ti-shield"></i></span>
@ -30,7 +30,7 @@
</div>
<MkAvatar class="avatar" :user="user" indicator/>
<div class="title">
<MkUserName :user="user" :nowrap="false" class="name"/>
<span class="name _nowrap">{{ user.name ?? user.username }}</span>
<div class="bottom">
<span class="username"><MkAcct :user="user" :detail="true"/></span>
<span v-if="user.isAdmin" :title="i18n.ts.isAdmin" style="color: var(--badge);"><i class="ti ti-shield"></i></span>

View file

@ -156,6 +156,13 @@ hr {
-webkit-touch-callout: none;
}
._nowrap {
white-space: pre;
word-wrap: normal; // https://codeday.me/jp/qa/20190424/690106.html
overflow: clip;
text-overflow: ellipsis;
}
._ghost {
@extend ._noSelect;
pointer-events: none;

View file

@ -6,9 +6,7 @@
</div>
<div :class="$style.bodyContainer">
<div :class="$style.body">
<MkA :class="$style.name" :to="userPage($i)">
<MkUserName :user="$i"/>
</MkA>
<MkA :class="$style.name" :to="userPage($i)" class="_nowrap">{{ $i.name ?? $i.username }}</MkA>
<div :class="$style.username"><MkAcct :user="$i" detail/></div>
</div>
</div>