limit length of instance name in mutes

This commit is contained in:
Hazelnoot 2025-06-29 16:05:53 -04:00
parent 9f0fdbbb51
commit 376997cbcc

View file

@ -28,7 +28,7 @@ Displays a placeholder for a muted note.
</I18n>
<I18n v-if="mute.instanceMandatoryCW" :src="i18n.ts.instanceIsFlaggedAs" tag="small">
<template #name>
{{ note.user.instance?.name ?? note.user.host }}
{{ instanceName }}
</template>
<template #cw>
{{ mute.instanceMandatoryCW }}
@ -77,6 +77,7 @@ Displays a placeholder for a muted note.
<script setup lang="ts">
import * as Misskey from 'misskey-js';
import { computed, ref, useTemplateRef, defineExpose } from 'vue';
import { host } from '@@/js/config.js';
import type { Ref } from 'vue';
import { i18n } from '@/i18n.js';
import { prefer } from '@/preferences.js';
@ -109,6 +110,18 @@ const mutedWords = computed(() => mute.value.softMutedWords?.join(', '));
const isExpanded = computed(() => expandNote.value || !mute.value.hasMute);
const rootClass = computed(() => isExpanded.value ? props.expandedClass : undefined);
const instanceName = computed(() => {
if (props.note.user.instance?.name) {
if (props.note.user.instance.name.length <= 32) {
return props.note.user.instance.name;
}
return `${props.note.user.instance.name.substring(0, 30)}...`;
}
return props.note.user.host ?? host;
});
const rootEl = useTemplateRef('rootEl');
defineExpose({
rootEl: rootEl as Ref<HTMLElement | null>,