2019-12-03 11:29:51 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
import { Refs } from '@/shims-vue';
|
|
|
|
import { ActorType, IActor } from '@/types/actor';
|
|
|
|
import { IFollower } from '@/types/actor/follower.model';
|
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class RelayMixin extends Vue {
|
|
|
|
$refs!: Refs<{
|
|
|
|
table: any,
|
|
|
|
}>;
|
|
|
|
|
|
|
|
checkedRows: IFollower[] = [];
|
|
|
|
page: number = 1;
|
2019-12-18 10:11:50 +01:00
|
|
|
perPage: number = 10;
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
toggle(row) {
|
|
|
|
this.$refs.table.toggleDetails(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
async onPageChange(page: number) {
|
|
|
|
this.page = page;
|
|
|
|
await this.$apollo.queries.relayFollowings.fetchMore({
|
|
|
|
variables: {
|
|
|
|
page: this.page,
|
|
|
|
limit: this.perPage,
|
|
|
|
},
|
|
|
|
updateQuery: (previousResult, { fetchMoreResult }) => {
|
|
|
|
if (!fetchMoreResult) return previousResult;
|
|
|
|
const newFollowings = fetchMoreResult.relayFollowings.elements;
|
|
|
|
return {
|
|
|
|
relayFollowings: {
|
|
|
|
__typename: previousResult.relayFollowings.__typename,
|
|
|
|
total: previousResult.relayFollowings.total,
|
|
|
|
elements: [...previousResult.relayFollowings.elements, ...newFollowings],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
isInstance(actor: IActor): boolean {
|
2019-12-17 17:10:37 +01:00
|
|
|
return actor.type === ActorType.APPLICATION && (actor.preferredUsername === 'relay' || actor.preferredUsername === actor.domain);
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
}
|