mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-11 08:54:07 +02:00
refactor(frontend): improve pagination implementation
This commit is contained in:
@@ -130,7 +130,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { nextTick, onActivated, onBeforeUnmount, onMounted, ref, useTemplateRef, watch, computed, TransitionGroup } from 'vue';
|
||||
import { nextTick, onActivated, onBeforeUnmount, onMounted, ref, useTemplateRef, watch, computed, TransitionGroup, markRaw } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import MkButton from './MkButton.vue';
|
||||
import type { MenuItem } from '@/types/menu.js';
|
||||
@@ -146,10 +146,10 @@ import { prefer } from '@/preferences.js';
|
||||
import { chooseFileFromPcAndUpload, selectDriveFolder } from '@/utility/drive.js';
|
||||
import { store } from '@/store.js';
|
||||
import { isSeparatorNeeded, getSeparatorInfo, makeDateGroupedTimelineComputedRef } from '@/utility/timeline-date-separate.js';
|
||||
import { usePagination } from '@/composables/use-pagination.js';
|
||||
import { globalEvents, useGlobalEvent } from '@/events.js';
|
||||
import { checkDragDataType, getDragData, setDragData } from '@/drag-and-drop.js';
|
||||
import { getDriveFileMenu } from '@/utility/get-drive-file-menu.js';
|
||||
import { Paginator } from '@/utility/paginator.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
initialFolder?: Misskey.entities.DriveFolder['id'] | null;
|
||||
@@ -195,33 +195,23 @@ const fetching = ref(true);
|
||||
|
||||
const sortModeSelect = ref<NonNullable<Misskey.entities.DriveFilesRequest['sort']>>('+createdAt');
|
||||
|
||||
const filesPaginator = usePagination({
|
||||
ctx: {
|
||||
endpoint: 'drive/files',
|
||||
limit: 30,
|
||||
canFetchDetection: 'limit',
|
||||
params: computed(() => ({
|
||||
folderId: folder.value ? folder.value.id : null,
|
||||
type: props.type,
|
||||
sort: sortModeSelect.value,
|
||||
})),
|
||||
},
|
||||
autoInit: false,
|
||||
autoReInit: false,
|
||||
});
|
||||
const filesPaginator = markRaw(new Paginator('drive/files', {
|
||||
limit: 30,
|
||||
canFetchDetection: 'limit',
|
||||
params: () => ({ // 自動でリロードしたくないためcomputedParamsは使わない
|
||||
folderId: folder.value ? folder.value.id : null,
|
||||
type: props.type,
|
||||
sort: sortModeSelect.value,
|
||||
}),
|
||||
}));
|
||||
|
||||
const foldersPaginator = usePagination({
|
||||
ctx: {
|
||||
endpoint: 'drive/folders',
|
||||
limit: 30,
|
||||
canFetchDetection: 'limit',
|
||||
params: computed(() => ({
|
||||
folderId: folder.value ? folder.value.id : null,
|
||||
})),
|
||||
},
|
||||
autoInit: false,
|
||||
autoReInit: false,
|
||||
});
|
||||
const foldersPaginator = markRaw(new Paginator('drive/folders', {
|
||||
limit: 30,
|
||||
canFetchDetection: 'limit',
|
||||
params: () => ({ // 自動でリロードしたくないためcomputedParamsは使わない
|
||||
folderId: folder.value ? folder.value.id : null,
|
||||
}),
|
||||
}));
|
||||
|
||||
const filesTimeline = makeDateGroupedTimelineComputedRef(filesPaginator.items, 'month');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user