From 3c5ed0ffbba9783bcc2437a588aa3cbc808a33da Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:18:36 +0900 Subject: enhance(frontend): improve modlog pagination --- packages/frontend/src/pages/admin/modlog.vue | 84 +++++++++++++++++----------- 1 file changed, 50 insertions(+), 34 deletions(-) (limited to 'packages/frontend/src/pages/admin') diff --git a/packages/frontend/src/pages/admin/modlog.vue b/packages/frontend/src/pages/admin/modlog.vue index 9ccc1cb0a0..9c1c1d0cc2 100644 --- a/packages/frontend/src/pages/admin/modlog.vue +++ b/packages/frontend/src/pages/admin/modlog.vue @@ -7,29 +7,32 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+ + -
+ - - - - + + + + + + {{ i18n.ts.loadMore }}
@@ -46,39 +49,51 @@ import MkInput from '@/components/MkInput.vue'; import MkTl from '@/components/MkTl.vue'; import { i18n } from '@/i18n.js'; import { definePage } from '@/page.js'; -import { misskeyApi } from '@/utility/misskey-api.js'; +import { prefer } from '@/preferences.js'; +import { usePagination } from '@/composables/use-pagination.js'; +import MkPullToRefresh from '@/components/MkPullToRefresh.vue'; import MkButton from '@/components/MkButton.vue'; +import MkPaginationControl from '@/components/MkPaginationControl.vue'; +const order = ref<'newest' | 'oldest'>('newest'); +const date = ref(null); const type = ref(null); const moderatorId = ref(''); -const timeline = ref([]); +const paginator = usePagination({ + ctx: { + endpoint: 'admin/show-moderation-logs', + limit: 20, + canFetchDetection: 'limit', + params: computed(() => ({ + type: type.value, + userId: moderatorId.value === '' ? null : moderatorId.value, + })), + }, +}); -watch([type, moderatorId], async () => { - const res = await misskeyApi('admin/show-moderation-logs', { - type: type.value, - userId: moderatorId.value === '' ? null : moderatorId.value, +watch([order, date], () => { + paginator.updateCtxPartial({ + order: order.value, + initialDirection: order.value === 'oldest' ? 'newer' : 'older', + initialDate: date.value, }); - timeline.value = res.map(x => ({ +}, { immediate: false }); + +const timeline = computed(() => { + return paginator.items.value.map(x => ({ id: x.id, timestamp: x.createdAt, data: x, })); -}, { immediate: true }); +}); function fetchMore() { - const last = timeline.value[timeline.value.length - 1]; - misskeyApi('admin/show-moderation-logs', { - type: type.value, - userId: moderatorId.value === '' ? null : moderatorId.value, - untilId: last.id, - }).then(res => { - timeline.value.push(...res.map(x => ({ - id: x.id, - timestamp: x.createdAt, - data: x, - }))); - }); + if (order.value === 'oldest') { + paginator.fetchNewer(); + } else { + paginator.fetchOlder(); + } } const headerActions = computed(() => []); @@ -90,3 +105,4 @@ definePage(() => ({ icon: 'ti ti-list-search', })); + -- cgit v1.2.3-freya