wip: migrate paging components to composition api

#7681
This commit is contained in:
syuilo
2022-01-09 21:35:35 +09:00
parent a10be38d0e
commit 586c11251a
8 changed files with 374 additions and 677 deletions

View File

@ -1,60 +1,36 @@
<template>
<div v-sticky-container class="yrzkoczt">
<MkTab v-model="with_" class="tab">
<MkTab v-model="include" class="tab">
<option :value="null">{{ $ts.notes }}</option>
<option value="replies">{{ $ts.notesAndReplies }}</option>
<option value="files">{{ $ts.withFiles }}</option>
</MkTab>
<XNotes ref="timeline" :no-gap="true" :pagination="pagination" @before="$emit('before')" @after="e => $emit('after', e)"/>
<XNotes ref="timeline" :no-gap="true" :pagination="pagination"/>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
<script lang="ts" setup>
import { ref, computed } from 'vue';
import * as misskey from 'misskey-js';
import XNotes from '@/components/notes.vue';
import MkTab from '@/components/tab.vue';
import * as os from '@/os';
export default defineComponent({
components: {
XNotes,
MkTab,
},
const props = defineProps<{
user: misskey.entities.UserDetailed;
}>();
props: {
user: {
type: Object,
required: true,
},
},
const include = ref<string | null>(null);
data() {
return {
date: null,
with_: null,
pagination: {
endpoint: 'users/notes',
limit: 10,
params: init => ({
userId: this.user.id,
includeReplies: this.with_ === 'replies',
withFiles: this.with_ === 'files',
untilDate: init ? undefined : (this.date ? this.date.getTime() : undefined),
})
}
};
},
watch: {
user() {
this.$refs.timeline.reload();
},
with_() {
this.$refs.timeline.reload();
},
},
});
const pagination = {
endpoint: 'users/notes' as const,
limit: 10,
params: computed(() => ({
userId: props.user.id,
includeReplies: include.value === 'replies',
withFiles: include.value === 'files',
})),
};
</script>
<style lang="scss" scoped>