diff --git a/packages/frontend/src/composables/use-pagination.ts b/packages/frontend/src/composables/use-pagination.ts index 8dd3b888db..92d7227a71 100644 --- a/packages/frontend/src/composables/use-pagination.ts +++ b/packages/frontend/src/composables/use-pagination.ts @@ -35,10 +35,15 @@ export type PagingCtx(props: { ctx: PagingCtx; + autoInit?: boolean; + autoReInit?: boolean; useShallowRef?: boolean; }) { const items = props.useShallowRef ? shallowRef([]) : ref([]); @@ -49,8 +54,9 @@ export function usePagination [props.ctx.endpoint, props.ctx.params], init, { deep: true }); + if (props.autoReInit !== false) { + watch(() => [props.ctx.endpoint, props.ctx.params], init, { deep: true }); + } function getNewestId(): string | null | undefined { // 様々な要因により並び順は保証されないのでソートが必要 @@ -92,12 +98,20 @@ export function usePagination { + }).finally(() => { fetchingOlder.value = false; }); } @@ -232,9 +253,11 @@ export function usePagination { - init(); - }); + if (props.autoInit !== false) { + onMounted(() => { + init(); + }); + } return { items: items as DeepReadonly>,