Fix GraphQL cache errors because of missing id on some queries
Also moves some queries to cache-and-network policy and improve typescript a bit Closes #387 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -109,7 +109,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
|
||||
apollo: {
|
||||
futureParticipations: {
|
||||
query: LOGGED_USER_PARTICIPATIONS,
|
||||
fetchPolicy: "network-only",
|
||||
fetchPolicy: "cache-and-network",
|
||||
variables: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
@@ -122,7 +122,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
|
||||
},
|
||||
drafts: {
|
||||
query: LOGGED_USER_DRAFTS,
|
||||
fetchPolicy: "network-only",
|
||||
fetchPolicy: "cache-and-network",
|
||||
variables: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
@@ -131,7 +131,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
|
||||
},
|
||||
pastParticipations: {
|
||||
query: LOGGED_USER_PARTICIPATIONS,
|
||||
fetchPolicy: "network-only",
|
||||
fetchPolicy: "cache-and-network",
|
||||
variables: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
|
||||
@@ -185,12 +185,10 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue, Watch, Ref } from "vue-property-decorator";
|
||||
import { DataProxy } from "apollo-cache";
|
||||
import {
|
||||
IEvent,
|
||||
IEventParticipantStats,
|
||||
IParticipant,
|
||||
Participant,
|
||||
ParticipantRole,
|
||||
} from "../../types/event.model";
|
||||
import { PARTICIPANTS, UPDATE_PARTICIPANT } from "../../graphql/event";
|
||||
@@ -198,7 +196,6 @@ import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";
|
||||
import { IPerson, usernameWithDomain } from "../../types/actor";
|
||||
import { CONFIG } from "../../graphql/config";
|
||||
import { IConfig } from "../../types/config.model";
|
||||
import { Paginate } from "../../types/paginate";
|
||||
import { nl2br } from "../../utils/html";
|
||||
import { asyncForEach } from "../../utils/asyncForEach";
|
||||
import RouteName from "../../router/name";
|
||||
@@ -214,7 +211,7 @@ const MESSAGE_ELLIPSIS_LENGTH = 130;
|
||||
config: CONFIG,
|
||||
event: {
|
||||
query: PARTICIPANTS,
|
||||
fetchPolicy: "network-only",
|
||||
fetchPolicy: "cache-and-network",
|
||||
variables() {
|
||||
return {
|
||||
uuid: this.eventId,
|
||||
@@ -260,7 +257,7 @@ export default class Participants extends Vue {
|
||||
|
||||
@Ref("queueTable") readonly queueTable!: any;
|
||||
|
||||
mounted() {
|
||||
mounted(): void {
|
||||
const roleQuery = this.$route.query.role as string;
|
||||
if (Object.values(ParticipantRole).includes(roleQuery as ParticipantRole)) {
|
||||
this.roles = roleQuery as ParticipantRole;
|
||||
@@ -273,7 +270,7 @@ export default class Participants extends Vue {
|
||||
}
|
||||
|
||||
@Watch("page")
|
||||
loadMoreParticipants() {
|
||||
loadMoreParticipants(): void {
|
||||
this.$apollo.queries.event.fetchMore({
|
||||
// New variables
|
||||
variables: {
|
||||
@@ -299,9 +296,9 @@ export default class Participants extends Vue {
|
||||
});
|
||||
}
|
||||
|
||||
async acceptParticipant(participant: IParticipant) {
|
||||
async acceptParticipant(participant: IParticipant): Promise<void> {
|
||||
try {
|
||||
const { data } = await this.$apollo.mutate({
|
||||
await this.$apollo.mutate({
|
||||
mutation: UPDATE_PARTICIPANT,
|
||||
variables: {
|
||||
id: participant.id,
|
||||
@@ -314,9 +311,9 @@ export default class Participants extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async refuseParticipant(participant: IParticipant) {
|
||||
async refuseParticipant(participant: IParticipant): Promise<void> {
|
||||
try {
|
||||
const { data } = await this.$apollo.mutate({
|
||||
await this.$apollo.mutate({
|
||||
mutation: UPDATE_PARTICIPANT,
|
||||
variables: {
|
||||
id: participant.id,
|
||||
@@ -329,14 +326,14 @@ export default class Participants extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async acceptParticipants(participants: IParticipant[]) {
|
||||
async acceptParticipants(participants: IParticipant[]): Promise<void> {
|
||||
await asyncForEach(participants, async (participant: IParticipant) => {
|
||||
await this.acceptParticipant(participant);
|
||||
});
|
||||
this.checkedRows = [];
|
||||
}
|
||||
|
||||
async refuseParticipants(participants: IParticipant[]) {
|
||||
async refuseParticipants(participants: IParticipant[]): Promise<void> {
|
||||
await asyncForEach(participants, async (participant: IParticipant) => {
|
||||
await this.refuseParticipant(participant);
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ import RouteName from "../../router/name";
|
||||
apollo: {
|
||||
membershipsPages: {
|
||||
query: LOGGED_USER_MEMBERSHIPS,
|
||||
fetchPolicy: "network-only",
|
||||
fetchPolicy: "cache-and-network",
|
||||
variables: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
|
||||
@@ -163,7 +163,7 @@ import Subtitle from "../components/Utils/Subtitle.vue";
|
||||
config: CONFIG,
|
||||
currentUserParticipations: {
|
||||
query: LOGGED_USER_PARTICIPATIONS,
|
||||
fetchPolicy: "network-only",
|
||||
fetchPolicy: "cache-and-network",
|
||||
variables() {
|
||||
const lastWeek = new Date();
|
||||
lastWeek.setDate(new Date().getDate() - 7);
|
||||
|
||||
Reference in New Issue
Block a user