mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-23 16:54:10 +02:00
refactor(frontend): improve pagination implementation
This commit is contained in:
@@ -103,19 +103,18 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MkFoldableSection v-if="notePagination">
|
||||
<MkFoldableSection v-if="paginator">
|
||||
<template #header>{{ i18n.ts.searchResult }}</template>
|
||||
<MkNotesTimeline :key="`searchNotes:${key}`" :pagination="notePagination"/>
|
||||
<MkNotesTimeline :key="`searchNotes:${key}`" :paginator="paginator"/>
|
||||
</MkFoldableSection>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, shallowRef, toRef } from 'vue';
|
||||
import type * as Misskey from 'misskey-js';
|
||||
import type { PagingCtx } from '@/composables/use-pagination.js';
|
||||
import { $i } from '@/i.js';
|
||||
import { computed, markRaw, ref, shallowRef, toRef } from 'vue';
|
||||
import { host as localHost } from '@@/js/config.js';
|
||||
import type * as Misskey from 'misskey-js';
|
||||
import { $i } from '@/i.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import * as os from '@/os.js';
|
||||
@@ -128,6 +127,7 @@ import MkInput from '@/components/MkInput.vue';
|
||||
import MkNotesTimeline from '@/components/MkNotesTimeline.vue';
|
||||
import MkRadios from '@/components/MkRadios.vue';
|
||||
import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
query?: string;
|
||||
@@ -144,7 +144,7 @@ const props = withDefaults(defineProps<{
|
||||
const router = useRouter();
|
||||
|
||||
const key = ref(0);
|
||||
const notePagination = ref<PagingCtx<'notes/search'>>();
|
||||
const paginator = shallowRef<Paginator<'notes/search'> | null>(null);
|
||||
|
||||
const searchQuery = ref(toRef(props, 'query').value);
|
||||
const hostInput = ref(toRef(props, 'host').value);
|
||||
@@ -299,13 +299,12 @@ async function search() {
|
||||
}
|
||||
}
|
||||
|
||||
notePagination.value = {
|
||||
endpoint: 'notes/search',
|
||||
paginator.value = markRaw(new Paginator('notes/search', {
|
||||
limit: 10,
|
||||
params: {
|
||||
...searchParams.value,
|
||||
},
|
||||
};
|
||||
}));
|
||||
|
||||
key.value++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user