mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-04 11:56:13 +02:00
refactor(frontend): improve pagination implementation
This commit is contained in:
@@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
{{ i18n.ts.drafts }} ({{ currentDraftsCount }}/{{ $i?.policies.noteDraftLimit }})
|
||||
</template>
|
||||
<div class="_spacer">
|
||||
<MkPagination ref="pagingEl" :pagination="paging" withControl>
|
||||
<MkPagination :paginator="paginator" withControl>
|
||||
<template #empty>
|
||||
<MkResult type="empty" :text="i18n.ts._drafts.noDrafts"/>
|
||||
</template>
|
||||
@@ -100,9 +100,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, shallowRef, useTemplateRef } from 'vue';
|
||||
import { ref, shallowRef, markRaw } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import type { PagingCtx } from '@/composables/use-pagination.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import MkModalWindow from '@/components/MkModalWindow.vue';
|
||||
@@ -111,6 +110,7 @@ import { i18n } from '@/i18n.js';
|
||||
import * as os from '@/os.js';
|
||||
import { $i } from '@/i.js';
|
||||
import { misskeyApi } from '@/utility/misskey-api';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: 'restore', draft: Misskey.entities.NoteDraft): void;
|
||||
@@ -118,12 +118,9 @@ const emit = defineEmits<{
|
||||
(ev: 'closed'): void;
|
||||
}>();
|
||||
|
||||
const paging = {
|
||||
endpoint: 'notes/drafts/list',
|
||||
const paginator = markRaw(new Paginator('notes/drafts/list', {
|
||||
limit: 10,
|
||||
} satisfies PagingCtx;
|
||||
|
||||
const pagingComponent = useTemplateRef('pagingEl');
|
||||
}));
|
||||
|
||||
const currentDraftsCount = ref(0);
|
||||
misskeyApi('notes/drafts/count').then((count) => {
|
||||
@@ -151,7 +148,7 @@ async function deleteDraft(draft: Misskey.entities.NoteDraft) {
|
||||
if (canceled) return;
|
||||
|
||||
os.apiWithDialog('notes/drafts/delete', { draftId: draft.id }).then(() => {
|
||||
pagingComponent.value?.paginator.reload();
|
||||
paginator.reload();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user