wip: refactor(client): migrate paging components to composition api
This commit is contained in:
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user