Skip to content

Commit

Permalink
[wip] fixme: speaking and screen update watchers are not working
Browse files Browse the repository at this point in the history
[skip ci]

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Jul 9, 2024
1 parent 4bbaf56 commit a45394e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/components/CallView/CallView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,16 @@ export default {
},

screens() {
console.log('screens watcher')
this._setScreenVisible()

},
// screens: {
// deep: true,
// handler() {
// this._setScreenVisible()
// }
// },

callParticipantModelsWithScreen(newValue, previousValue) {
// Everytime a new screen is shared, switch to promoted view
Expand Down Expand Up @@ -458,6 +465,7 @@ export default {
* @param {Array} models the array of CallParticipantModels
*/
updateDataFromCallParticipantModels(models) {
console.log('updateDataFromCallParticipantModels', models)
const addedModels = models.filter(model => !this.sharedDatas[model.attributes.peerId])
const removedModelIds = Object.keys(this.sharedDatas).filter(sharedDataId => models.find(model => model.attributes.peerId === sharedDataId) === undefined)

Expand All @@ -467,15 +475,15 @@ export default {
delete this.sharedDatas[removedModelId]

this.speakingUnwatchers[removedModelId]()
// Not reactive, but not a problem
// FIXME Not reactive, but not a problem?
delete this.speakingUnwatchers[removedModelId]

this.screenUnwatchers[removedModelId]()
// Not reactive, but not a problem
// FIXME Not reactive, but not a problem?
delete this.screenUnwatchers[removedModelId]

this.raisedHandUnwatchers[removedModelId]()
// Not reactive, but not a problem
// FIXME Not reactive, but not a problem?
delete this.raisedHandUnwatchers[removedModelId]

const index = this.speakers.findIndex(speaker => speaker.id === removedModelId)
Expand All @@ -493,7 +501,7 @@ export default {

this.sharedDatas[addedModel.attributes.peerId] = sharedData

// Not reactive, but not a problem
// FIXME Not reactive, but not a problem?
this.speakingUnwatchers[addedModel.attributes.peerId] = this.$watch(function() {
return addedModel.attributes.speaking
}, function(speaking) {
Expand All @@ -505,14 +513,14 @@ export default {
active: false,
})

// Not reactive, but not a problem
// FIXME Not reactive, but not a problem?
this.screenUnwatchers[addedModel.attributes.peerId] = this.$watch(function() {
return addedModel.attributes.screen
}, function(screen) {
this._setScreenAvailable(addedModel.attributes.peerId, screen)
})

// Not reactive, but not a problem
// FIXME Not reactive, but not a problem? - at least works
this.raisedHandUnwatchers[addedModel.attributes.peerId] = this.$watch(function() {
return addedModel.attributes.raisedHand
}, function(raisedHand) {
Expand Down Expand Up @@ -581,6 +589,7 @@ export default {
},

_setScreenAvailable(id, screen) {
console.log('_setScreenAvailable', id, screen)
if (screen) {
this.screens.unshift(id)

Expand Down Expand Up @@ -628,6 +637,7 @@ export default {
},

_setScreenVisible() {
console.log('_setScreenVisible', this.sharedDatas)
this.localSharedData.screenVisible = false

Object.values(this.sharedDatas).forEach(sharedData => {
Expand Down
1 change: 1 addition & 0 deletions src/utils/webrtc/models/CallParticipantModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ CallParticipantModel.prototype = {
},

_handlePeerStreamAdded(peer) {
// FIXME store as a non-reactive, raw value using toRaw to not have proxy created for Peer at all.
if (toRaw(this.get('peer')) === toRaw(peer)) {
this.set('stream', this.get('peer').stream || null)

Expand Down

0 comments on commit a45394e

Please sign in to comment.