Skip to content

Commit

Permalink
feat(store): remove newGroupConversationStore
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Jan 13, 2024
1 parent 15b3a09 commit bb57b58
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 211 deletions.
10 changes: 3 additions & 7 deletions src/components/ContactSelectionBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</span>
<NcButton type="tertiary-no-background"
:aria-label="removeLabel"
@click="removeParticipantFromSelection(participant)">
@click="$emit('update', participant)">
<template #icon>
<Close :size="16" />
</template>
Expand Down Expand Up @@ -66,6 +66,8 @@ export default {
},
},

emits: ['update'],

setup() {
return { AVATAR }
},
Expand All @@ -81,12 +83,6 @@ export default {
return t('spreed', 'Remove participant {name}', { name: this.displayName })
},
},

methods: {
removeParticipantFromSelection(participant) {
this.$store.dispatch('updateSelectedParticipants', participant)
},
},
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
group>
<ContactSelectionBubble v-for="participant in selectedParticipants"
:key="participant.source + participant.id"
:participant="participant" />
:participant="participant"
@update="updateSelectedParticipants" />
</TransitionWrapper>

<!-- Search results -->
Expand Down Expand Up @@ -125,6 +126,8 @@ export default {
},
},

emits: ['update:selected-participants'],

setup() {
const wrapper = ref(null)
const setContacts = ref(null)
Expand Down Expand Up @@ -247,15 +250,24 @@ export default {
},

updateSelectedParticipants(participant) {
this.$store.dispatch('updateSelectedParticipants', participant)
const isSelected = this.selectedParticipants.some(selected => {
return selected.id === participant.id && selected.source === participant.source
})
const payload = isSelected
? this.selectedParticipants.filter(selected => {
return selected.id !== participant.id || selected.source !== participant.source
})
: [...this.selectedParticipants, participant]

this.$emit('update:selected-participants', payload)
},

addParticipantPhone() {
if (!this.participantPhoneItem?.phoneNumber) {
return
}

this.$store.dispatch('updateSelectedParticipants', this.participantPhoneItem)
this.updateSelectedParticipants(this.participantPhoneItem)
}
},
}
Expand Down
20 changes: 12 additions & 8 deletions src/components/NewConversationDialog/NewConversationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<!-- Second page -->
<NewConversationContactsPage v-if="page === 1"
class="new-group-conversation__content"
:selected-participants="selectedParticipants"
:selected-participants.sync="selectedParticipants"
:can-moderate-sip-dial-out="canModerateSipDialOut"
:conversation-name="conversationName" />
</div>
Expand Down Expand Up @@ -125,6 +125,8 @@
</template>

<script>
import { provide, ref } from 'vue'

import AlertCircle from 'vue-material-design-icons/AlertCircle.vue'
import Check from 'vue-material-design-icons/Check.vue'

Expand Down Expand Up @@ -179,7 +181,13 @@ export default {

setup() {
const isInCall = useIsInCall()
return { isInCall }
const selectedParticipants = ref([])
provide('selectedParticipants', selectedParticipants)

return {
isInCall,
selectedParticipants,
}
},

data() {
Expand Down Expand Up @@ -213,10 +221,6 @@ export default {
disabled() {
return this.conversationName === '' || (this.newConversation.hasPassword && this.password === '')
},

selectedParticipants() {
return this.$store.getters.selectedParticipants
},
},

watch: {
Expand Down Expand Up @@ -254,7 +258,7 @@ export default {
if (item) {
// Preload the conversation name from group selection
this.newConversation.displayName = item.label
this.$store.dispatch('updateSelectedParticipants', item)
this.selectedParticipants.push(item)
}

this.showModal()
Expand All @@ -274,7 +278,7 @@ export default {
this.password = ''
this.listable = CONVERSATION.LISTABLE.NONE
this.isAvatarEdited = false
this.$store.dispatch('purgeNewGroupConversationStore')
this.selectedParticipants = []
},

switchToPage(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@
</template>

<script>

import isEqual from 'lodash/isEqual.js'
import { inject } from 'vue'

import Account from 'vue-material-design-icons/Account.vue'
import Bell from 'vue-material-design-icons/Bell.vue'
Expand Down Expand Up @@ -412,7 +411,12 @@ export default {

setup() {
const isInCall = useIsInCall()
return { isInCall }
const selectedParticipants = inject('selectedParticipants', [])

return {
isInCall,
selectedParticipants
}
},

data() {
Expand Down Expand Up @@ -538,16 +542,11 @@ export default {
* @return {boolean}
*/
isSelected() {
if (this.selectable) {
let isSelected = false
this.$store.getters.selectedParticipants.forEach(selectedParticipant => {
if (isEqual(selectedParticipant, this.participant)) {
isSelected = true
}
return this.selectable
? this.selectedParticipants.some(selected => {
return selected.id === this.participant.id && selected.source === this.participant.source
})
return isSelected
}
return false
: false
},

/**
Expand Down
4 changes: 0 additions & 4 deletions src/store/conversationsStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,6 @@ describe('conversationsStore', () => {
})

test('sets default permissions for a conversation', async () => {
expect(store.getters.selectedParticipants).toStrictEqual([])

await store.dispatch('setConversationPermissions', { token: testToken, permissions })

expect(setConversationPermissions).toHaveBeenCalledWith(testToken, permissions)
Expand All @@ -1235,8 +1233,6 @@ describe('conversationsStore', () => {
})

test('sets default permissions for a call', async () => {
expect(store.getters.selectedParticipants).toStrictEqual([])

await store.dispatch('setCallPermissions', { token: testToken, permissions })

expect(setCallPermissions).toHaveBeenCalledWith(testToken, permissions)
Expand Down
122 changes: 0 additions & 122 deletions src/store/newGroupConversationStore.js

This file was deleted.

53 changes: 0 additions & 53 deletions src/store/newGroupConversationStore.spec.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/store/storeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import callViewStore from './callViewStore.js'
import conversationsStore from './conversationsStore.js'
import fileUploadStore from './fileUploadStore.js'
import messagesStore from './messagesStore.js'
import newGroupConversationStore from './newGroupConversationStore.js'
import participantsStore from './participantsStore.js'
import pollStore from './pollStore.js'
import sidebarStore from './sidebarStore.js'
Expand All @@ -44,7 +43,6 @@ export default {
conversationsStore,
fileUploadStore,
messagesStore,
newGroupConversationStore,
participantsStore,
sidebarStore,
soundsStore,
Expand Down

0 comments on commit bb57b58

Please sign in to comment.