2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Vue, Ref } from "vue-property-decorator";
|
|
|
|
import { ActorType, IActor } from "@/types/actor";
|
|
|
|
import { IFollower } from "@/types/actor/follower.model";
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
@Component
|
|
|
|
export default class RelayMixin extends Vue {
|
2020-02-18 08:57:00 +01:00
|
|
|
@Ref("table") readonly table!: any;
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
checkedRows: IFollower[] = [];
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
page = 1;
|
|
|
|
|
|
|
|
perPage = 10;
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
toggle(row: Record<string, unknown>): void {
|
2020-02-18 08:57:00 +01:00
|
|
|
this.table.toggleDetails(row);
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
async onPageChange(page: number): Promise<void> {
|
2019-12-03 11:29:51 +01:00
|
|
|
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],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
static isInstance(actor: IActor): boolean {
|
|
|
|
return (
|
|
|
|
actor.type === ActorType.APPLICATION &&
|
|
|
|
(actor.preferredUsername === "relay" || actor.preferredUsername === actor.domain)
|
|
|
|
);
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
}
|