Fix followings/followers pagination

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-27 09:13:17 +01:00
parent 4206ff50f6
commit bf0ec150cd
4 changed files with 96 additions and 46 deletions

View File

@@ -12,7 +12,7 @@
backend-pagination
:total="relayFollowers.total"
:per-page="perPage"
@page-change="onPageChange"
@page-change="onFollowersPageChange"
checkable
checkbox-position="left"
>
@@ -103,18 +103,11 @@
import { Component, Mixins } from "vue-property-decorator";
import { SnackbarProgrammatic as Snackbar } from "buefy";
import { formatDistanceToNow } from "date-fns";
import { ACCEPT_RELAY, REJECT_RELAY, RELAY_FOLLOWERS } from "../../graphql/admin";
import { Paginate } from "../../types/paginate";
import { ACCEPT_RELAY, REJECT_RELAY } from "../../graphql/admin";
import { IFollower } from "../../types/actor/follower.model";
import RelayMixin from "../../mixins/relay";
@Component({
apollo: {
relayFollowers: {
query: RELAY_FOLLOWERS,
fetchPolicy: "cache-and-network",
},
},
metaInfo() {
return {
title: this.$t("Followers") as string,
@@ -123,8 +116,6 @@ import RelayMixin from "../../mixins/relay";
},
})
export default class Followers extends Mixins(RelayMixin) {
relayFollowers: Paginate<IFollower> = { elements: [], total: 0 };
RelayMixin = RelayMixin;
formatDistanceToNow = formatDistanceToNow;

View File

@@ -25,7 +25,7 @@
backend-pagination
:total="relayFollowings.total"
:per-page="perPage"
@page-change="onPageChange"
@page-change="onFollowingsPageChange"
checkable
checkbox-position="left"
>
@@ -101,18 +101,12 @@
import { Component, Mixins } from "vue-property-decorator";
import { SnackbarProgrammatic as Snackbar } from "buefy";
import { formatDistanceToNow } from "date-fns";
import { ADD_RELAY, RELAY_FOLLOWINGS, REMOVE_RELAY } from "../../graphql/admin";
import { ADD_RELAY, REMOVE_RELAY } from "../../graphql/admin";
import { IFollower } from "../../types/actor/follower.model";
import { Paginate } from "../../types/paginate";
import RelayMixin from "../../mixins/relay";
@Component({
apollo: {
relayFollowings: {
query: RELAY_FOLLOWINGS,
fetchPolicy: "cache-and-network",
},
},
metaInfo() {
return {
title: this.$t("Followings") as string,
@@ -121,8 +115,6 @@ import RelayMixin from "../../mixins/relay";
},
})
export default class Followings extends Mixins(RelayMixin) {
relayFollowings: Paginate<IFollower> = { elements: [], total: 0 };
newRelayAddress = "";
RelayMixin = RelayMixin;
@@ -137,12 +129,11 @@ export default class Followings extends Mixins(RelayMixin) {
variables: {
address: this.newRelayAddress,
},
// TODO: Handle cache update properly without refreshing
});
await this.$apollo.queries.relayFollowings.refetch();
this.newRelayAddress = "";
} catch (e) {
Snackbar.open({ message: e.message, type: "is-danger", position: "is-bottom" });
} catch (err) {
Snackbar.open({ message: err.message, type: "is-danger", position: "is-bottom" });
}
}