wip: refactor(client): migrate paging components to composition api

This commit is contained in:
syuilo
2022-01-10 03:30:35 +09:00
parent 186a9e3b41
commit 06125e6820
15 changed files with 51 additions and 122 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div>
<MkPagination v-slot="{items}" ref="list" :pagination="pagination" class="mk-following-or-followers">
<MkPagination v-slot="{items}" ref="list" :pagination="type === 'following' ? followingPagination : followersPagination" class="mk-following-or-followers">
<div class="users _isolated">
<MkUserInfo v-for="user in items.map(x => type === 'following' ? x.followee : x.follower)" :key="user.id" class="user" :user="user"/>
</div>
@@ -9,7 +9,7 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { computed, defineComponent } from 'vue';
import MkUserInfo from '@/components/user-info.vue';
import MkPagination from '@/components/ui/pagination.vue';
@@ -32,25 +32,22 @@ export default defineComponent({
data() {
return {
pagination: {
endpoint: () => this.type === 'following' ? 'users/following' : 'users/followers',
followingPagination: {
endpoint: 'users/following',
limit: 20,
params: {
params: computed(() => ({
userId: this.user.id,
}
})),
},
followersPagination: {
endpoint: 'users/followers',
limit: 20,
params: computed(() => ({
userId: this.user.id,
})),
},
};
},
watch: {
type() {
this.$refs.list.reload();
},
user() {
this.$refs.list.reload();
}
}
});
</script>