diff --git a/src/pages/EventRequests.vue b/src/pages/EventRequests.vue index cb7a854..f98ef7e 100644 --- a/src/pages/EventRequests.vue +++ b/src/pages/EventRequests.vue @@ -245,18 +245,19 @@ export default defineComponent({ tooltip: 'Einladung löschen', color: 'negative', onClick: () => { - void store.rejectInvitation(row.id); - onRequest({ - pagination: pagination.value, - filter: () => [], - getCellValue: () => [], + void store.rejectInvitation(row.id).then(() => { + onRequest({ + pagination: pagination.value, + filter: () => [], + getCellValue: () => [], + }); + const notification = all_notifications.value.find( + (n) => (n.data).invitation === row.id + ); + if (notification !== undefined) { + void mainStore.removeNotification(notification.id); + } }); - const notification = all_notifications.value.find( - (n) => (n.data).invitation === row.id - ); - if (notification !== undefined) { - void mainStore.removeNotification(notification.id); - } }, }; const accept = { @@ -264,18 +265,19 @@ export default defineComponent({ tooltip: 'Einladung annehmen', color: 'primary', onClick: () => { - void store.acceptInvitation(row.id); - onRequest({ - pagination: pagination.value, - filter: () => [], - getCellValue: () => [], + void store.acceptInvitation(row.id).then(() => { + onRequest({ + pagination: pagination.value, + filter: () => [], + getCellValue: () => [], + }); + const notification = all_notifications.value.find( + (n) => (n.data).invitation === row.id + ); + if (notification !== undefined) { + void mainStore.removeNotification(notification.id); + } }); - const notification = all_notifications.value.find( - (n) => (n.data).invitation === row.id - ); - if (notification !== undefined) { - void mainStore.removeNotification(notification.id); - } }, }; if (sender) { diff --git a/src/store/index.ts b/src/store/index.ts index de935c4..ed26a54 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -204,13 +204,21 @@ export const useEventStore = defineStore({ }, async rejectInvitation(invite: FG.Invitation | number) { - return api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`); + try { + await api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`); + const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite)); + if (idx >= 0) this.invitations.splice(idx, 1); + } catch (e) {} }, async acceptInvitation(invite: FG.Invitation | number) { - return api.put(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`, { - accept: true, - }); + try { + await api.put(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`, { + accept: true, + }); + const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite)); + if (idx >= 0) this.invitations.splice(idx, 1); + } catch (e) {} }, }, });