Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(frontend): ページ内でdocument.titleを直接操作させない, タイポ修正 など #288

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/invite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<MkStickyContainer>
<template #header><MkPageHeader/></template>
<MKSpacer v-if="!instance.disableRegistration || !($i && ($i.isAdmin || $i.policies.canInvite))" :contentMax="1200">
<MkSpacer v-if="!instance.disableRegistration || !($i && ($i.isAdmin || $i.policies.canInvite))" :contentMax="1200">
<div :class="$style.root">
<img :class="$style.img" :src="serverErrorImageUrl" class="_ghost"/>
<div :class="$style.text">
<i class="ti ti-alert-triangle"></i>
{{ i18n.ts.nothing }}
</div>
</div>
</MKSpacer>
</MkSpacer>
<MkSpacer v-else :contentMax="800">
<div class="_gaps_m" style="text-align: center;">
<div v-if="resetCycle && inviteLimit">{{ i18n.tsx.inviteLimitResetCycle({ time: resetCycle, limit: inviteLimit }) }}</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<MkStickyContainer>
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
<MKSpacer v-if="!(typeof error === 'undefined')" :contentMax="1200">
<MkSpacer v-if="error != null" :contentMax="1200">
<div :class="$style.root">
<img :class="$style.img" :src="serverErrorImageUrl" class="_ghost"/>
<p :class="$style.text">
<i class="ti ti-alert-triangle"></i>
{{ i18n.ts.nothing }}
</p>
</div>
</MKSpacer>
</MkSpacer>
<MkSpacer v-else-if="list" :contentMax="700" :class="$style.main">
<div v-if="list" class="members _margin">
<div :class="$style.member_text">{{ i18n.ts.members }}</div>
Expand Down Expand Up @@ -50,7 +50,7 @@ const props = defineProps<{
}>();

const list = ref<Misskey.entities.UserList | null>(null);
const error = ref();
const error = ref<unknown | null>(null);
const users = ref<Misskey.entities.UserDetailed[]>([]);

function fetchList(): void {
Expand Down
25 changes: 12 additions & 13 deletions packages/frontend/src/pages/role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<MkStickyContainer>
<template #header><MkPageHeader v-model:tab="tab" :tabs="headerTabs"/></template>
<MKSpacer v-if="!(typeof error === 'undefined')" :contentMax="1200">
<MkSpacer v-if="error != null" :contentMax="1200">
<div :class="$style.root">
<img :class="$style.img" :src="serverErrorImageUrl" class="_ghost"/>
<p :class="$style.text">
<i class="ti ti-alert-triangle"></i>
{{ error }}
</p>
</div>
</MKSpacer>
</MkSpacer>
<MkSpacer v-else-if="tab === 'users'" :contentMax="1200">
<div class="_gaps_s">
<div v-if="role">{{ role.description }}</div>
Expand All @@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</MkSpacer>
<MkSpacer v-else-if="tab === 'timeline'" :contentMax="700">
<MkTimeline v-if="visible" ref="timeline" src="role" :role="props.role"/>
<MkTimeline v-if="visible" ref="timeline" src="role" :role="props.roleId"/>
<div v-else-if="!visible" class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
Expand All @@ -38,7 +38,6 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { computed, watch, ref } from 'vue';
import * as Misskey from 'misskey-js';
import { instanceName } from '@@/js/config.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkUserList from '@/components/MkUserList.vue';
import { definePageMetadata } from '@/scripts/page-metadata.js';
Expand All @@ -47,39 +46,39 @@ import MkTimeline from '@/components/MkTimeline.vue';
import { serverErrorImageUrl, infoImageUrl } from '@/instance.js';

const props = withDefaults(defineProps<{
role: string;
roleId: string;
initialTab?: string;
}>(), {
initialTab: 'users',
});

// eslint-disable-next-line vue/no-setup-props-reactivity-loss
const tab = ref(props.initialTab);
const role = ref<Misskey.entities.Role>();
const error = ref();
const role = ref<Misskey.entities.Role | null>(null);
const error = ref<string | null>(null);
const visible = ref(false);

watch(() => props.role, () => {
watch(() => props.roleId, () => {
misskeyApi('roles/show', {
roleId: props.role,
roleId: props.roleId,
}).then(res => {
role.value = res;
document.title = `${role.value.name} | ${instanceName}`;
error.value = null;
visible.value = res.isExplorable && res.isPublic;
}).catch((err) => {
if (err.code === 'NO_SUCH_ROLE') {
error.value = i18n.ts.noRole;
} else {
error.value = i18n.ts.somethingHappened;
}
document.title = `${error.value} | ${instanceName}`;
});
}, { immediate: true });

const users = computed(() => ({
endpoint: 'roles/users' as const,
limit: 30,
params: {
roleId: props.role,
roleId: props.roleId,
},
}));

Expand All @@ -94,7 +93,7 @@ const headerTabs = computed(() => [{
}]);

definePageMetadata(() => ({
title: role.value ? role.value.name : i18n.ts.role,
title: role.value ? role.value.name : (error.value ?? i18n.ts.role),
icon: 'ti ti-badge',
}));
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/router/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const routes: RouteDef[] = [{
component: page(() => import('@/pages/theme-editor.vue')),
loginRequired: true,
}, {
path: '/roles/:role',
path: '/roles/:roleId',
component: page(() => import('@/pages/role.vue')),
}, {
path: '/user-tags/:tag',
Expand Down
Loading