From 39931bf2ae10836dac75946615334b54279af1ce Mon Sep 17 00:00:00 2001 From: Phan An Date: Wed, 23 Aug 2023 23:46:44 +0200 Subject: [PATCH] fix: remove invitation after revocation --- resources/assets/js/services/invitationService.ts | 5 ++++- resources/assets/js/stores/userStore.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/services/invitationService.ts b/resources/assets/js/services/invitationService.ts index 8124e883..cb27d119 100644 --- a/resources/assets/js/services/invitationService.ts +++ b/resources/assets/js/services/invitationService.ts @@ -13,5 +13,8 @@ export const invitationService = { users.forEach(user => userStore.add(user)) }, - revoke: async (user: User) => await http.delete(`invitations`, { email: user.email }) + revoke: async (user: User) => { + await http.delete(`invitations`, { email: user.email }) + userStore.remove(user) + } } diff --git a/resources/assets/js/stores/userStore.ts b/resources/assets/js/stores/userStore.ts index 1748d96f..0a9d296c 100644 --- a/resources/assets/js/stores/userStore.ts +++ b/resources/assets/js/stores/userStore.ts @@ -85,8 +85,7 @@ export const userStore = { async destroy (user: User) { await http.delete(`users/${user.id}`) - this.state.users = differenceBy(this.state.users, [user], 'id') - this.vault.delete(user.id) + this.remove(user) // Mama, just killed a man // Put a gun against his head @@ -106,5 +105,10 @@ export const userStore = { // Mama, oooh // I don't want to die // I sometimes wish I'd never been born at all + }, + + remove (user: User) { + this.state.users = differenceBy(this.state.users, [user], 'id') + this.vault.delete(user.id) } }