mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-29 09:23:04 +00:00
fix(frontend): instance infoページで不必要なapiリクエストが飛ぶのを抑止 (#14515)
* fix(frontend): instance infoページで不必要なapiリクエストが飛ぶのを抑止 * fix
This commit is contained in:
parent
8d19bdbb65
commit
567acea2a3
2 changed files with 43 additions and 32 deletions
|
@ -13,29 +13,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts">
|
||||||
/* eslint-disable id-denylist --
|
export type ChartSrc =
|
||||||
Chart.js has a `data` attribute in most chart definitions, which triggers the
|
|
||||||
id-denylist violation when setting it. This is causing about 60+ lint issues.
|
|
||||||
As this is part of Chart.js's API it makes sense to disable the check here.
|
|
||||||
*/
|
|
||||||
import { onMounted, ref, shallowRef, watch } from 'vue';
|
|
||||||
import { Chart } from 'chart.js';
|
|
||||||
import * as Misskey from 'misskey-js';
|
|
||||||
import { misskeyApiGet } from '@/scripts/misskey-api.js';
|
|
||||||
import { defaultStore } from '@/store.js';
|
|
||||||
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
|
|
||||||
import { chartVLine } from '@/scripts/chart-vline.js';
|
|
||||||
import { alpha } from '@/scripts/color.js';
|
|
||||||
import date from '@/filters/date.js';
|
|
||||||
import bytes from '@/filters/bytes.js';
|
|
||||||
import { initChart } from '@/scripts/init-chart.js';
|
|
||||||
import { chartLegend } from '@/scripts/chart-legend.js';
|
|
||||||
import MkChartLegend from '@/components/MkChartLegend.vue';
|
|
||||||
|
|
||||||
initChart();
|
|
||||||
|
|
||||||
type ChartSrc =
|
|
||||||
| 'federation'
|
| 'federation'
|
||||||
| 'ap-request'
|
| 'ap-request'
|
||||||
| 'users'
|
| 'users'
|
||||||
|
@ -62,7 +41,30 @@ type ChartSrc =
|
||||||
| 'per-user-pv'
|
| 'per-user-pv'
|
||||||
| 'per-user-following'
|
| 'per-user-following'
|
||||||
| 'per-user-followers'
|
| 'per-user-followers'
|
||||||
| 'per-user-drive'
|
| 'per-user-drive';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
/* eslint-disable id-denylist --
|
||||||
|
Chart.js has a `data` attribute in most chart definitions, which triggers the
|
||||||
|
id-denylist violation when setting it. This is causing about 60+ lint issues.
|
||||||
|
As this is part of Chart.js's API it makes sense to disable the check here.
|
||||||
|
*/
|
||||||
|
import { onMounted, ref, shallowRef, watch } from 'vue';
|
||||||
|
import { Chart } from 'chart.js';
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
import { misskeyApiGet } from '@/scripts/misskey-api.js';
|
||||||
|
import { defaultStore } from '@/store.js';
|
||||||
|
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
|
||||||
|
import { chartVLine } from '@/scripts/chart-vline.js';
|
||||||
|
import { alpha } from '@/scripts/color.js';
|
||||||
|
import date from '@/filters/date.js';
|
||||||
|
import bytes from '@/filters/bytes.js';
|
||||||
|
import { initChart } from '@/scripts/init-chart.js';
|
||||||
|
import { chartLegend } from '@/scripts/chart-legend.js';
|
||||||
|
import MkChartLegend from '@/components/MkChartLegend.vue';
|
||||||
|
|
||||||
|
initChart();
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
src: ChartSrc;
|
src: ChartSrc;
|
||||||
|
|
|
@ -134,7 +134,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import MkChart from '@/components/MkChart.vue';
|
import MkChart, { type ChartSrc } from '@/components/MkChart.vue';
|
||||||
import MkObjectView from '@/components/MkObjectView.vue';
|
import MkObjectView from '@/components/MkObjectView.vue';
|
||||||
import FormLink from '@/components/form/link.vue';
|
import FormLink from '@/components/form/link.vue';
|
||||||
import MkLink from '@/components/MkLink.vue';
|
import MkLink from '@/components/MkLink.vue';
|
||||||
|
@ -150,7 +150,7 @@ import { iAmModerator, iAmAdmin } from '@/account.js';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
import MkPagination, { type Paging } from '@/components/MkPagination.vue';
|
||||||
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
||||||
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
|
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
|
||||||
import { dateString } from '@/filters/date.js';
|
import { dateString } from '@/filters/date.js';
|
||||||
|
@ -162,7 +162,7 @@ const props = defineProps<{
|
||||||
|
|
||||||
const tab = ref('overview');
|
const tab = ref('overview');
|
||||||
|
|
||||||
const chartSrc = ref('instance-requests');
|
const chartSrc = ref<ChartSrc>('instance-requests');
|
||||||
const meta = ref<Misskey.entities.AdminMetaResponse | null>(null);
|
const meta = ref<Misskey.entities.AdminMetaResponse | null>(null);
|
||||||
const instance = ref<Misskey.entities.FederationInstance | null>(null);
|
const instance = ref<Misskey.entities.FederationInstance | null>(null);
|
||||||
const suspensionState = ref<'none' | 'manuallySuspended' | 'goneSuspended' | 'autoSuspendedForNotResponding'>('none');
|
const suspensionState = ref<'none' | 'manuallySuspended' | 'goneSuspended' | 'autoSuspendedForNotResponding'>('none');
|
||||||
|
@ -173,7 +173,7 @@ const faviconUrl = ref<string | null>(null);
|
||||||
const moderationNote = ref('');
|
const moderationNote = ref('');
|
||||||
|
|
||||||
const usersPagination = {
|
const usersPagination = {
|
||||||
endpoint: iAmModerator ? 'admin/show-users' : 'users' as const,
|
endpoint: iAmModerator ? 'admin/show-users' : 'users',
|
||||||
limit: 10,
|
limit: 10,
|
||||||
params: {
|
params: {
|
||||||
sort: '+updatedAt',
|
sort: '+updatedAt',
|
||||||
|
@ -181,11 +181,14 @@ const usersPagination = {
|
||||||
hostname: props.host,
|
hostname: props.host,
|
||||||
},
|
},
|
||||||
offsetMode: true,
|
offsetMode: true,
|
||||||
};
|
} satisfies Paging;
|
||||||
|
|
||||||
watch(moderationNote, async () => {
|
if (iAmModerator) {
|
||||||
|
watch(moderationNote, async () => {
|
||||||
|
if (instance.value == null) return;
|
||||||
await misskeyApi('admin/federation/update-instance', { host: instance.value.host, moderationNote: moderationNote.value });
|
await misskeyApi('admin/federation/update-instance', { host: instance.value.host, moderationNote: moderationNote.value });
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function fetch(): Promise<void> {
|
async function fetch(): Promise<void> {
|
||||||
if (iAmAdmin) {
|
if (iAmAdmin) {
|
||||||
|
@ -203,6 +206,7 @@ async function fetch(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleBlock(): Promise<void> {
|
async function toggleBlock(): Promise<void> {
|
||||||
|
if (!iAmAdmin) return;
|
||||||
if (!meta.value) throw new Error('No meta?');
|
if (!meta.value) throw new Error('No meta?');
|
||||||
if (!instance.value) throw new Error('No instance?');
|
if (!instance.value) throw new Error('No instance?');
|
||||||
const { host } = instance.value;
|
const { host } = instance.value;
|
||||||
|
@ -212,6 +216,7 @@ async function toggleBlock(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleSilenced(): Promise<void> {
|
async function toggleSilenced(): Promise<void> {
|
||||||
|
if (!iAmAdmin) return;
|
||||||
if (!meta.value) throw new Error('No meta?');
|
if (!meta.value) throw new Error('No meta?');
|
||||||
if (!instance.value) throw new Error('No instance?');
|
if (!instance.value) throw new Error('No instance?');
|
||||||
const { host } = instance.value;
|
const { host } = instance.value;
|
||||||
|
@ -222,6 +227,7 @@ async function toggleSilenced(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleMediaSilenced(): Promise<void> {
|
async function toggleMediaSilenced(): Promise<void> {
|
||||||
|
if (!iAmAdmin) return;
|
||||||
if (!meta.value) throw new Error('No meta?');
|
if (!meta.value) throw new Error('No meta?');
|
||||||
if (!instance.value) throw new Error('No instance?');
|
if (!instance.value) throw new Error('No instance?');
|
||||||
const { host } = instance.value;
|
const { host } = instance.value;
|
||||||
|
@ -232,6 +238,7 @@ async function toggleMediaSilenced(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stopDelivery(): Promise<void> {
|
async function stopDelivery(): Promise<void> {
|
||||||
|
if (!iAmModerator) return;
|
||||||
if (!instance.value) throw new Error('No instance?');
|
if (!instance.value) throw new Error('No instance?');
|
||||||
suspensionState.value = 'manuallySuspended';
|
suspensionState.value = 'manuallySuspended';
|
||||||
await misskeyApi('admin/federation/update-instance', {
|
await misskeyApi('admin/federation/update-instance', {
|
||||||
|
@ -241,6 +248,7 @@ async function stopDelivery(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resumeDelivery(): Promise<void> {
|
async function resumeDelivery(): Promise<void> {
|
||||||
|
if (!iAmModerator) return;
|
||||||
if (!instance.value) throw new Error('No instance?');
|
if (!instance.value) throw new Error('No instance?');
|
||||||
suspensionState.value = 'none';
|
suspensionState.value = 'none';
|
||||||
await misskeyApi('admin/federation/update-instance', {
|
await misskeyApi('admin/federation/update-instance', {
|
||||||
|
@ -250,6 +258,7 @@ async function resumeDelivery(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshMetadata(): void {
|
function refreshMetadata(): void {
|
||||||
|
if (!iAmModerator) return;
|
||||||
if (!instance.value) throw new Error('No instance?');
|
if (!instance.value) throw new Error('No instance?');
|
||||||
misskeyApi('admin/federation/refresh-remote-instance-metadata', {
|
misskeyApi('admin/federation/refresh-remote-instance-metadata', {
|
||||||
host: instance.value.host,
|
host: instance.value.host,
|
||||||
|
|
Loading…
Reference in a new issue