Skip to content

Commit

Permalink
fix(InvitationHandler): minor fixes
Browse files Browse the repository at this point in the history
- don't mutate store
- check for empty object instead of array

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Mar 7, 2024
1 parent dac6f7a commit cc8174d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/components/LeftSidebar/InvitationHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ export default {
},

invitations() {
const pendingShares = this.federationStore.pendingShares
for (const id in pendingShares) {
pendingShares[id] = Object.assign({}, pendingShares[id], {
const invitations = {}
for (const id in this.federationStore.pendingShares) {
invitations[id] = {
...this.federationStore.pendingShares[id],
type: CONVERSATION.TYPE.GROUP,
isFederatedConversation: true,
isDummyConversation: true,
})
}
}
return pendingShares
return invitations
},
},

Expand All @@ -145,17 +146,19 @@ export default {
if (conversation?.token) {
this.$store.dispatch('addConversation', conversation)
}
if (this.invitations.length === 0) {
this.closeModal()
}
this.checkIfNoMoreInvitations()
},

async rejectShare(id) {
await this.federationStore.rejectShare(id)
if (this.invitations.length === 0) {
this.checkIfNoMoreInvitations()
},

checkIfNoMoreInvitations() {
if (Object.keys(this.invitations).length === 0) {
this.closeModal()
}
},
}
},
}
</script>
Expand Down

0 comments on commit cc8174d

Please sign in to comment.