wip
This commit is contained in:
parent
ba2029efb6
commit
7d867c8083
|
@ -43,6 +43,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { onMounted } from 'vue';
|
||||||
import type { PagingCtx } from '@/use/use-pagination.js';
|
import type { PagingCtx } from '@/use/use-pagination.js';
|
||||||
import { infoImageUrl } from '@/instance.js';
|
import { infoImageUrl } from '@/instance.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
@ -70,6 +71,10 @@ function appearFetchMore() {
|
||||||
paginator.fetchMore();
|
paginator.fetchMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
paginator.init();
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
paginator: paginator,
|
paginator: paginator,
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:moveClass=" $style.transition_x_move"
|
:moveClass=" $style.transition_x_move"
|
||||||
tag="div"
|
tag="div"
|
||||||
>
|
>
|
||||||
<template v-for="(note, i) in paginator.items.value" :key="note.id">
|
<template v-for="(note, i) in Array.from(paginator.items.value.values())" :key="note.id">
|
||||||
<div v-if="note._shouldInsertAd_" :class="[$style.noteWithAd, { '_gaps': !noGap }]" :data-scroll-anchor="note.id">
|
<div v-if="note._shouldInsertAd_" :class="[$style.noteWithAd, { '_gaps': !noGap }]" :data-scroll-anchor="note.id">
|
||||||
<MkNote :class="$style.note" :note="note" :withHardMute="true"/>
|
<MkNote :class="$style.note" :note="note" :withHardMute="true"/>
|
||||||
<div :class="$style.ad">
|
<div :class="$style.ad">
|
||||||
|
@ -40,7 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
</component>
|
</component>
|
||||||
<div v-show="paginator.canFetchMore.value" key="_more_">
|
<div v-show="paginator.canFetchMore.value" key="_more_">
|
||||||
<MkButton v-if="!paginator.moreFetching.value" v-appear="(prefer.s.enableInfiniteScroll && !props.disableAutoLoad) ? appearFetchMore : null" :class="$style.more" :wait="paginator.moreFetching.value" primary rounded @click="paginator.fetchMore">
|
<MkButton v-if="!paginator.moreFetching.value" v-appear="prefer.s.enableInfiniteScroll ? paginator.fetchMore : null" :class="$style.more" :wait="paginator.moreFetching.value" primary rounded @click="paginator.fetchMore">
|
||||||
{{ i18n.ts.loadMore }}
|
{{ i18n.ts.loadMore }}
|
||||||
</MkButton>
|
</MkButton>
|
||||||
<MkLoading v-else/>
|
<MkLoading v-else/>
|
||||||
|
@ -50,7 +50,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, watch, onUnmounted, provide, useTemplateRef, TransitionGroup } from 'vue';
|
import { computed, watch, onUnmounted, provide, useTemplateRef, TransitionGroup, onMounted } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import { useInterval } from '@@/js/use-interval.js';
|
import { useInterval } from '@@/js/use-interval.js';
|
||||||
import type { BasicTimelineType } from '@/timelines.js';
|
import type { BasicTimelineType } from '@/timelines.js';
|
||||||
|
@ -122,15 +122,13 @@ useInterval(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function prepend(note) {
|
function prepend(note) {
|
||||||
if (pagingComponent.value == null) return;
|
|
||||||
|
|
||||||
tlNotesCount++;
|
tlNotesCount++;
|
||||||
|
|
||||||
if (instance.notesPerOneAd > 0 && tlNotesCount % instance.notesPerOneAd === 0) {
|
if (instance.notesPerOneAd > 0 && tlNotesCount % instance.notesPerOneAd === 0) {
|
||||||
note._shouldInsertAd_ = true;
|
note._shouldInsertAd_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pagingComponent.value.prepend(note);
|
paginator.prepend(note);
|
||||||
|
|
||||||
if (props.sound) {
|
if (props.sound) {
|
||||||
sound.playMisskeySfx($i && (note.userId === $i.id) ? 'noteMy' : 'note');
|
sound.playMisskeySfx($i && (note.userId === $i.id) ? 'noteMy' : 'note');
|
||||||
|
@ -304,6 +302,10 @@ const paginator = usePagination({
|
||||||
ctx: paginationQuery,
|
ctx: paginationQuery,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
paginator.init();
|
||||||
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
disconnectChannel();
|
disconnectChannel();
|
||||||
});
|
});
|
||||||
|
|
|
@ -184,6 +184,10 @@ export function usePagination<T>(props: {
|
||||||
if (length >= MAX_ITEMS) canFetchMore.value = true;
|
if (length >= MAX_ITEMS) canFetchMore.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepend(item: MisskeyEntity) {
|
||||||
|
unshiftItems([item]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* アイテムを末尾に追加する(使うの?)
|
* アイテムを末尾に追加する(使うの?)
|
||||||
*/
|
*/
|
||||||
|
@ -209,6 +213,8 @@ export function usePagination<T>(props: {
|
||||||
reload,
|
reload,
|
||||||
fetchMore,
|
fetchMore,
|
||||||
fetchMoreAhead,
|
fetchMoreAhead,
|
||||||
|
unshiftItems,
|
||||||
|
prepend,
|
||||||
error,
|
error,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue