@@ -1010,20 +1010,25 @@ export default class Event extends EventMixin {
|
||||
query: EVENT_PERSON_PARTICIPATION,
|
||||
variables: { eventId: this.event.id, actorId: identity.id },
|
||||
});
|
||||
if (participationCachedData == null) return;
|
||||
const { person } = participationCachedData;
|
||||
if (person === null) {
|
||||
|
||||
if (participationCachedData?.person == undefined) {
|
||||
console.error(
|
||||
"Cannot update participation cache, because of null value."
|
||||
);
|
||||
return;
|
||||
}
|
||||
person.participations.elements.push(data.joinEvent);
|
||||
person.participations.total += 1;
|
||||
store.writeQuery({
|
||||
query: EVENT_PERSON_PARTICIPATION,
|
||||
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 }>({
|
||||
@@ -1038,18 +1043,24 @@ export default class Event extends EventMixin {
|
||||
);
|
||||
return;
|
||||
}
|
||||
const participantStats = { ...event.participantStats };
|
||||
|
||||
if (data.joinEvent.role === ParticipantRole.NOT_APPROVED) {
|
||||
event.participantStats.notApproved += 1;
|
||||
participantStats.notApproved += 1;
|
||||
} else {
|
||||
event.participantStats.going += 1;
|
||||
event.participantStats.participant += 1;
|
||||
participantStats.going += 1;
|
||||
participantStats.participant += 1;
|
||||
}
|
||||
|
||||
store.writeQuery({
|
||||
query: FETCH_EVENT,
|
||||
variables: { uuid: this.uuid },
|
||||
data: { event },
|
||||
data: {
|
||||
event: {
|
||||
...event,
|
||||
participantStats,
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user