TT#71912 Optimise muteState mutations

Change-Id: Ic427ec561d79c2b9521a86e259312aec8402b597
changes/40/35940/1
Carlo Venusino 6 years ago
parent f861e0e189
commit c3899a5595

@ -153,6 +153,7 @@
</template> </template>
<script> <script>
import _ from 'lodash';
import { import {
mapGetters, mapGetters,
mapState, mapState,
@ -293,7 +294,7 @@
}, },
toggleMuteAll(){ toggleMuteAll(){
this.$refs.popover.close(); this.$refs.popover.close();
if(this.mutedState.length < 1) { if(_.isEmpty(this.mutedState)) {
this.$store.dispatch('conference/muteAll'); this.$store.dispatch('conference/muteAll');
} }
else{ else{
@ -301,7 +302,7 @@
} }
}, },
muteLabel() { muteLabel() {
return this.mutedState.length < 1 return _.isEmpty(this.mutedState)
? this.$t('conferencing.muteAll') ? this.$t('conferencing.muteAll')
: this.$t('conferencing.unmuteAll'); : this.$t('conferencing.unmuteAll');
}, },

@ -57,6 +57,7 @@
</template> </template>
<script> <script>
import _ from 'lodash';
import { QIcon, QCard, QCardMedia, QCardTitle, QPopover, QList, QItem, QItemMain } from 'quasar-framework' import { QIcon, QCard, QCardMedia, QCardTitle, QPopover, QList, QItem, QItemMain } from 'quasar-framework'
import CscMedia from "../../CscMedia"; import CscMedia from "../../CscMedia";
import { import {
@ -133,7 +134,7 @@
this.assignStream(); this.assignStream();
}, },
mutedState(){ mutedState(){
this.isAudioMuted = this.mutedState.includes(this.remoteParticipant.id); this.isAudioMuted = _.has(this.mutedState, this.remoteParticipant.id);
this.$refs.cscMedia.toggleAudio(this.isAudioMuted); this.$refs.cscMedia.toggleAudio(this.isAudioMuted);
} }
} }

@ -25,7 +25,7 @@ export default {
leaveState: RequestState.initiated, leaveState: RequestState.initiated,
leaveError: null, leaveError: null,
participants: [], participants: [],
mutedState: [], mutedState: {},
remoteMediaStreams: {}, remoteMediaStreams: {},
selectedParticipant: null, selectedParticipant: null,
manualSelection: false manualSelection: false
@ -231,14 +231,10 @@ export default {
state.manualSelection = val; state.manualSelection = val;
}, },
addMutedState(state, participantId){ addMutedState(state, participantId){
if(!state.mutedState[participantId]){ Vue.set(state.mutedState, participantId, participantId);
state.mutedState.push(participantId);
}
}, },
removeMutedState(state, participantId){ removeMutedState(state, participantId){
state.mutedState = state.mutedState.filter(($participant) => { Vue.delete(state.mutedState, participantId);
return participantId !== $participant;
});
} }
}, },
actions: { actions: {

Loading…
Cancel
Save