fix: directionをMkPaginationに移動

This commit is contained in:
kakkokari-gtyih 2025-08-21 19:04:51 +09:00
parent ddb7c6e154
commit 41e0242b40
4 changed files with 16 additions and 16 deletions

View File

@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template> <template>
<MkPagination :paginator="paginator" :autoLoad="autoLoad" :pullToRefresh="pullToRefresh" :withControl="withControl"> <MkPagination :paginator="paginator" :direction="direction" :autoLoad="autoLoad" :pullToRefresh="pullToRefresh" :withControl="withControl">
<template #empty><MkResult type="empty" :text="i18n.ts.noNotes"/></template> <template #empty><MkResult type="empty" :text="i18n.ts.noNotes"/></template>
<template #default="{ items: notes }"> <template #default="{ items: notes }">
@ -50,11 +50,14 @@ import { isSeparatorNeeded, getSeparatorInfo } from '@/utility/timeline-date-sep
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
paginator: T; paginator: T;
noGap?: boolean; noGap?: boolean;
direction?: 'up' | 'down' | 'both';
autoLoad?: boolean; autoLoad?: boolean;
pullToRefresh?: boolean; pullToRefresh?: boolean;
withControl?: boolean; withControl?: boolean;
}>(), { }>(), {
autoLoad: true, autoLoad: true,
direction: 'down',
pullToRefresh: true, pullToRefresh: true,
withControl: true, withControl: true,
}); });

View File

@ -25,14 +25,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
<div v-else key="_root_" class="_gaps"> <div v-else key="_root_" class="_gaps">
<div v-if="paginator.direction === 'up' || paginator.direction === 'both'" v-show="upButtonVisible"> <div v-if="direction === 'up' || direction === 'both'" v-show="upButtonVisible">
<MkButton v-if="!upButtonLoading" :class="$style.more" primary rounded @click="upButtonClick"> <MkButton v-if="!upButtonLoading" :class="$style.more" primary rounded @click="upButtonClick">
{{ i18n.ts.loadMore }} {{ i18n.ts.loadMore }}
</MkButton> </MkButton>
<MkLoading v-else/> <MkLoading v-else/>
</div> </div>
<slot :items="unref(paginator.items)" :fetching="paginator.fetching.value || paginator.fetchingOlder.value"></slot> <slot :items="unref(paginator.items)" :fetching="paginator.fetching.value || paginator.fetchingOlder.value"></slot>
<div v-if="paginator.direction === 'down' || paginator.direction === 'both'" v-show="downButtonVisible"> <div v-if="direction === 'down' || direction === 'both'" v-show="downButtonVisible">
<MkButton v-if="!downButtonLoading" :class="$style.more" primary rounded @click="downButtonClick"> <MkButton v-if="!downButtonLoading" :class="$style.more" primary rounded @click="downButtonClick">
{{ i18n.ts.loadMore }} {{ i18n.ts.loadMore }}
</MkButton> </MkButton>
@ -58,11 +58,20 @@ import * as os from '@/os.js';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
paginator: T; paginator: T;
//
// up:
// down: (default)
// both:
// NOTE:
direction?: 'up' | 'down' | 'both';
autoLoad?: boolean; autoLoad?: boolean;
pullToRefresh?: boolean; pullToRefresh?: boolean;
withControl?: boolean; withControl?: boolean;
}>(), { }>(), {
autoLoad: true, autoLoad: true,
direction: 'down',
pullToRefresh: true, pullToRefresh: true,
withControl: false, withControl: false,
}); });

View File

@ -9,7 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<Transition :name="prefer.s.animation ? 'fade' : ''" mode="out-in"> <Transition :name="prefer.s.animation ? 'fade' : ''" mode="out-in">
<div v-if="note"> <div v-if="note">
<div v-if="showNext" class="_margin"> <div v-if="showNext" class="_margin">
<MkNotesTimeline :withControl="false" :pullToRefresh="false" class="" :paginator="showNext === 'channel' ? nextChannelPaginator : nextUserPaginator" :noGap="true"/> <MkNotesTimeline direction="up" :withControl="false" :pullToRefresh="false" class="" :paginator="showNext === 'channel' ? nextChannelPaginator : nextUserPaginator" :noGap="true"/>
</div> </div>
<div class="_margin"> <div class="_margin">
@ -90,7 +90,6 @@ const nextUserPaginator = markRaw(new Paginator('users/notes', {
limit: 10, limit: 10,
initialId: props.noteId, initialId: props.noteId,
initialDirection: 'newer', initialDirection: 'newer',
direction: 'up',
computedParams: computed(() => note.value ? ({ computedParams: computed(() => note.value ? ({
userId: note.value.userId, userId: note.value.userId,
}) : undefined), }) : undefined),
@ -108,7 +107,6 @@ const nextChannelPaginator = markRaw(new Paginator('channels/timeline', {
limit: 10, limit: 10,
initialId: props.noteId, initialId: props.noteId,
initialDirection: 'newer', initialDirection: 'newer',
direction: 'up',
computedParams: computed(() => note.value && note.value.channelId != null ? ({ computedParams: computed(() => note.value && note.value.channelId != null ? ({
channelId: note.value.channelId, channelId: note.value.channelId,
}) : undefined), }) : undefined),

View File

@ -46,7 +46,6 @@ export interface IPaginator<T = unknown, _T = T & MisskeyEntity> {
initialDirection: 'newer' | 'older'; initialDirection: 'newer' | 'older';
noPaging: boolean; noPaging: boolean;
searchQuery: Ref<null | string>; searchQuery: Ref<null | string>;
direction: 'up' | 'down' | 'both';
order: Ref<'newest' | 'oldest'>; order: Ref<'newest' | 'oldest'>;
init(): Promise<void>; init(): Promise<void>;
@ -102,13 +101,6 @@ export class Paginator<
private aheadQueue: T[] = []; private aheadQueue: T[] = [];
private useShallowRef: SRef; private useShallowRef: SRef;
// ページネーションを進める方向
// up: 上方向
// down: 下方向 (default)
// both: 双方向
// NOTE: この方向はページネーションの方向であって、アイテムの並び順ではない
public direction: 'up' | 'down' | 'both' = 'down';
// 配列内の要素をどのような順序で並べるか // 配列内の要素をどのような順序で並べるか
// newest: 新しいものが先頭 (default) // newest: 新しいものが先頭 (default)
// oldest: 古いものが先頭 // oldest: 古いものが先頭
@ -132,7 +124,6 @@ export class Paginator<
initialDate?: number | null; initialDate?: number | null;
initialDirection?: 'newer' | 'older'; initialDirection?: 'newer' | 'older';
direction?: 'up' | 'down' | 'both';
order?: 'newest' | 'oldest'; order?: 'newest' | 'oldest';
// 一部のAPIはさらに遡れる場合でもパフォーマンス上の理由でlimit以下の結果を返す場合があり、その場合はsafe、それ以外はlimitにすることを推奨 // 一部のAPIはさらに遡れる場合でもパフォーマンス上の理由でlimit以下の結果を返す場合があり、その場合はsafe、それ以外はlimitにすることを推奨
@ -155,7 +146,6 @@ export class Paginator<
this.params = props.params ?? {}; this.params = props.params ?? {};
this.computedParams = props.computedParams ?? null; this.computedParams = props.computedParams ?? null;
this.order = ref(props.order ?? 'newest'); this.order = ref(props.order ?? 'newest');
this.direction = props.direction ?? 'down';
this.initialId = props.initialId ?? null; this.initialId = props.initialId ?? null;
this.initialDate = props.initialDate ?? null; this.initialDate = props.initialDate ?? null;
this.initialDirection = props.initialDirection ?? 'older'; this.initialDirection = props.initialDirection ?? 'older';