Fix event participation
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
732785919a
commit
04f902333b
@ -44,19 +44,18 @@ export default class EventMixin extends mixins(Vue) {
|
|||||||
});
|
});
|
||||||
if (participationCachedData == null) return;
|
if (participationCachedData == null) return;
|
||||||
const { person } = participationCachedData;
|
const { person } = participationCachedData;
|
||||||
if (person === null) {
|
|
||||||
console.error(
|
|
||||||
"Cannot update participation cache, because of null value."
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
[participation] = person.participations.elements;
|
[participation] = person.participations.elements;
|
||||||
person.participations.elements = [];
|
|
||||||
person.participations.total = 0;
|
store.modify({
|
||||||
store.writeQuery({
|
id: `Person:${actorId}`,
|
||||||
query: EVENT_PERSON_PARTICIPATION,
|
fields: {
|
||||||
variables: { eventId: event.id, actorId },
|
participations() {
|
||||||
data: { person },
|
return {
|
||||||
|
elements: [],
|
||||||
|
total: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,21 +69,27 @@ export default class EventMixin extends mixins(Vue) {
|
|||||||
console.error("Cannot update event cache, because of null value.");
|
console.error("Cannot update event cache, because of null value.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const participantStats = { ...eventCached.participantStats };
|
||||||
if (
|
if (
|
||||||
participation &&
|
participation &&
|
||||||
participation.role === ParticipantRole.NOT_APPROVED
|
participation?.role === ParticipantRole.NOT_APPROVED
|
||||||
) {
|
) {
|
||||||
eventCached.participantStats.notApproved -= 1;
|
participantStats.notApproved -= 1;
|
||||||
} else if (anonymousParticipationConfirmed === false) {
|
} else if (anonymousParticipationConfirmed === false) {
|
||||||
eventCached.participantStats.notConfirmed -= 1;
|
participantStats.notConfirmed -= 1;
|
||||||
} else {
|
} else {
|
||||||
eventCached.participantStats.going -= 1;
|
participantStats.going -= 1;
|
||||||
eventCached.participantStats.participant -= 1;
|
participantStats.participant -= 1;
|
||||||
}
|
}
|
||||||
store.writeQuery({
|
store.writeQuery({
|
||||||
query: FETCH_EVENT,
|
query: FETCH_EVENT,
|
||||||
variables: { uuid: event.uuid },
|
variables: { uuid: event.uuid },
|
||||||
data: { event: eventCached },
|
data: {
|
||||||
|
event: {
|
||||||
|
...eventCached,
|
||||||
|
participantStats,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1010,20 +1010,25 @@ export default class Event extends EventMixin {
|
|||||||
query: EVENT_PERSON_PARTICIPATION,
|
query: EVENT_PERSON_PARTICIPATION,
|
||||||
variables: { eventId: this.event.id, actorId: identity.id },
|
variables: { eventId: this.event.id, actorId: identity.id },
|
||||||
});
|
});
|
||||||
if (participationCachedData == null) return;
|
|
||||||
const { person } = participationCachedData;
|
if (participationCachedData?.person == undefined) {
|
||||||
if (person === null) {
|
|
||||||
console.error(
|
console.error(
|
||||||
"Cannot update participation cache, because of null value."
|
"Cannot update participation cache, because of null value."
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
person.participations.elements.push(data.joinEvent);
|
|
||||||
person.participations.total += 1;
|
|
||||||
store.writeQuery({
|
store.writeQuery({
|
||||||
query: EVENT_PERSON_PARTICIPATION,
|
query: EVENT_PERSON_PARTICIPATION,
|
||||||
variables: { eventId: this.event.id, actorId: identity.id },
|
variables: { eventId: this.event.id, actorId: identity.id },
|
||||||
data: { person },
|
data: {
|
||||||
|
person: {
|
||||||
|
...participationCachedData?.person,
|
||||||
|
participations: {
|
||||||
|
elements: [data.joinEvent],
|
||||||
|
total: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const cachedData = store.readQuery<{ event: IEvent }>({
|
const cachedData = store.readQuery<{ event: IEvent }>({
|
||||||
@ -1038,18 +1043,24 @@ export default class Event extends EventMixin {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const participantStats = { ...event.participantStats };
|
||||||
|
|
||||||
if (data.joinEvent.role === ParticipantRole.NOT_APPROVED) {
|
if (data.joinEvent.role === ParticipantRole.NOT_APPROVED) {
|
||||||
event.participantStats.notApproved += 1;
|
participantStats.notApproved += 1;
|
||||||
} else {
|
} else {
|
||||||
event.participantStats.going += 1;
|
participantStats.going += 1;
|
||||||
event.participantStats.participant += 1;
|
participantStats.participant += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.writeQuery({
|
store.writeQuery({
|
||||||
query: FETCH_EVENT,
|
query: FETCH_EVENT,
|
||||||
variables: { uuid: this.uuid },
|
variables: { uuid: this.uuid },
|
||||||
data: { event },
|
data: {
|
||||||
|
event: {
|
||||||
|
...event,
|
||||||
|
participantStats,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user