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>

View File

@ -9,7 +9,7 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { computed, defineComponent } from 'vue';
import MkGalleryPostPreview from '@/components/gallery-post-preview.vue';
import MkPagination from '@/components/ui/pagination.vue';
@ -31,18 +31,12 @@ export default defineComponent({
pagination: {
endpoint: 'users/gallery/posts',
limit: 6,
params: () => ({
params: computed(() => ({
userId: this.user.id
})
})),
},
};
},
watch: {
user() {
this.$refs.list.reload();
}
}
});
</script>

View File

@ -7,7 +7,7 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { computed, defineComponent } from 'vue';
import MkPagePreview from '@/components/page-preview.vue';
import MkPagination from '@/components/ui/pagination.vue';
@ -29,18 +29,12 @@ export default defineComponent({
pagination: {
endpoint: 'users/pages',
limit: 20,
params: {
params: computed(() => ({
userId: this.user.id,
}
})),
},
};
},
watch: {
user() {
this.$refs.list.reload();
}
}
});
</script>

View File

@ -14,7 +14,7 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { computed, defineComponent } from 'vue';
import MkPagination from '@/components/ui/pagination.vue';
import MkNote from '@/components/note.vue';
import MkReactionIcon from '@/components/reaction-icon.vue';
@ -38,18 +38,12 @@ export default defineComponent({
pagination: {
endpoint: 'users/reactions',
limit: 20,
params: {
params: computed(() => ({
userId: this.user.id,
}
})),
},
};
},
watch: {
user() {
this.$refs.list.reload();
}
},
});
</script>