From 4e80c526a370926d93ff52de327341aea552792e Mon Sep 17 00:00:00 2001 From: Astagor Date: Thu, 14 May 2020 14:18:04 +0200 Subject: [PATCH 1/3] Fixed to work on filmstrip. Changed logic, use setSelectedPeer --- app/src/RoomClient.js | 6 ++-- app/src/Spotlights.js | 80 ++++++++++++------------------------------- 2 files changed, 26 insertions(+), 60 deletions(-) diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 143aea9..1703205 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -304,12 +304,14 @@ export default class RoomClient { case String.fromCharCode(37): { - this._spotlights.setPrevAsSelected(); + const newPeerId = this._spotlights.getPrevAsSelected(store.getState().room.selectedPeerId); + if (newPeerId) this.setSelectedPeer(newPeerId); break; } case String.fromCharCode(39): { - this._spotlights.setNextAsSelected(); + const newPeerId = this._spotlights.getNextAsSelected(store.getState().room.selectedPeerId); + if (newPeerId) this.setSelectedPeer(newPeerId); break; } case 'A': // Activate advanced mode diff --git a/app/src/Spotlights.js b/app/src/Spotlights.js index 5d9f406..afa4b06 100644 --- a/app/src/Spotlights.js +++ b/app/src/Spotlights.js @@ -46,90 +46,54 @@ export default class Spotlights extends EventEmitter } } - setNextAsSelected() + getNextAsSelected(peerId) { - let peerId = null; - - if (this._selectedSpotlights.length > 0) - { - peerId = this._selectedSpotlights[0]; - } - else if (this._unmutablePeerList.length > 0) - { + let newSelectedPeer; + if (peerId == null && this._unmutablePeerList.length > 0) { peerId = this._unmutablePeerList[0]; } - if (peerId != null && - this._currentSpotlights.length < this._unmutablePeerList.length) - { - const oldIndex = this._unmutablePeerList.indexOf(peerId); - + if (peerId != null && this._currentSpotlights.length < this._unmutablePeerList.length) { + let oldIndex = this._unmutablePeerList.indexOf(peerId); let index = oldIndex; - index++; - do - { - if (index >= this._unmutablePeerList.length) - { + for (let i = 0; i < this._unmutablePeerList.length; i++) { + if (index >= this._unmutablePeerList.length) { index = 0; } - const newSelectedPeer = this._unmutablePeerList[index]; - - if (!this._currentSpotlights.includes(newSelectedPeer)) - { - this.setPeerSpotlight(newSelectedPeer); + newSelectedPeer = this._unmutablePeerList[index]; + if (!this._currentSpotlights.includes(newSelectedPeer)) { break; } index++; - if (index === oldIndex) - { - break; - } - } while (true); + } } + return newSelectedPeer; } - setPrevAsSelected() + getPrevAsSelected(peerId) { - let peerId = null; - - if (this._selectedSpotlights.length > 0) - { - peerId = this._selectedSpotlights[0]; - } - else if (this._unmutablePeerList.length > 0) - { + let newSelectedPeer; + if (peerId == null && this._unmutablePeerList.length > 0) { peerId = this._unmutablePeerList[0]; } - if (peerId != null && - this._currentSpotlights.length < this._unmutablePeerList.length) - { - const oldIndex = this._unmutablePeerList.indexOf(peerId); - + if (peerId != null && this._currentSpotlights.length < this._unmutablePeerList.length) { + let oldIndex = this._unmutablePeerList.indexOf(peerId); let index = oldIndex; - index--; - do - { - if (index < 0) - { + for (let i = 0; i < this._unmutablePeerList.length; i++) { + if (index < 0) { index = this._unmutablePeerList.length - 1; } - const newSelectedPeer = this._unmutablePeerList[index]; - - if (!this._currentSpotlights.includes(newSelectedPeer)) - { - this.setPeerSpotlight(newSelectedPeer); + newSelectedPeer = this._unmutablePeerList[index]; + if (!this._currentSpotlights.includes(newSelectedPeer)) { break; } index--; - if (index === oldIndex) - { - break; - } - } while (true); + } } + return newSelectedPeer; } setPeerSpotlight(peerId) From ceebea6a400e21e700fd70cb099e7666f3a21d02 Mon Sep 17 00:00:00 2001 From: Astagor Date: Thu, 14 May 2020 14:23:31 +0200 Subject: [PATCH 2/3] Fixed lint --- app/src/Spotlights.js | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/app/src/Spotlights.js b/app/src/Spotlights.js index afa4b06..6df7f1d 100644 --- a/app/src/Spotlights.js +++ b/app/src/Spotlights.js @@ -48,21 +48,28 @@ export default class Spotlights extends EventEmitter getNextAsSelected(peerId) { - let newSelectedPeer; - if (peerId == null && this._unmutablePeerList.length > 0) { + let newSelectedPeer = null; + + if (peerId == null && this._unmutablePeerList.length > 0) + { peerId = this._unmutablePeerList[0]; } - if (peerId != null && this._currentSpotlights.length < this._unmutablePeerList.length) { - let oldIndex = this._unmutablePeerList.indexOf(peerId); + if (peerId != null && this._currentSpotlights.length < this._unmutablePeerList.length) + { + const oldIndex = this._unmutablePeerList.indexOf(peerId); + let index = oldIndex; + index++; - for (let i = 0; i < this._unmutablePeerList.length; i++) { + for (let i = 0; i < this._unmutablePeerList.length; i++) + { if (index >= this._unmutablePeerList.length) { index = 0; } newSelectedPeer = this._unmutablePeerList[index]; - if (!this._currentSpotlights.includes(newSelectedPeer)) { + if (!this._currentSpotlights.includes(newSelectedPeer)) + { break; } index++; @@ -73,21 +80,28 @@ export default class Spotlights extends EventEmitter getPrevAsSelected(peerId) { - let newSelectedPeer; - if (peerId == null && this._unmutablePeerList.length > 0) { + let newSelectedPeer = null; + + if (peerId == null && this._unmutablePeerList.length > 0) + { peerId = this._unmutablePeerList[0]; } - if (peerId != null && this._currentSpotlights.length < this._unmutablePeerList.length) { - let oldIndex = this._unmutablePeerList.indexOf(peerId); + if (peerId != null && this._currentSpotlights.length < this._unmutablePeerList.length) + { + const oldIndex = this._unmutablePeerList.indexOf(peerId); + let index = oldIndex; + index--; - for (let i = 0; i < this._unmutablePeerList.length; i++) { + for (let i = 0; i < this._unmutablePeerList.length; i++) + { if (index < 0) { index = this._unmutablePeerList.length - 1; } newSelectedPeer = this._unmutablePeerList[index]; - if (!this._currentSpotlights.includes(newSelectedPeer)) { + if (!this._currentSpotlights.includes(newSelectedPeer)) + { break; } index--; From daf958d6273c992b52e440a950f0f8aabb28fe59 Mon Sep 17 00:00:00 2001 From: Astagor Date: Thu, 14 May 2020 14:27:03 +0200 Subject: [PATCH 3/3] Fixed lint 2 --- app/src/RoomClient.js | 8 ++++++-- app/src/Spotlights.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 1703205..16f0dd4 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -304,13 +304,17 @@ export default class RoomClient { case String.fromCharCode(37): { - const newPeerId = this._spotlights.getPrevAsSelected(store.getState().room.selectedPeerId); + const newPeerId = this._spotlights.getPrevAsSelected( + store.getState().room.selectedPeerId); + if (newPeerId) this.setSelectedPeer(newPeerId); break; } case String.fromCharCode(39): { - const newPeerId = this._spotlights.getNextAsSelected(store.getState().room.selectedPeerId); + const newPeerId = this._spotlights.getNextAsSelected( + store.getState().room.selectedPeerId); + if (newPeerId) this.setSelectedPeer(newPeerId); break; } diff --git a/app/src/Spotlights.js b/app/src/Spotlights.js index 6df7f1d..10d6638 100644 --- a/app/src/Spotlights.js +++ b/app/src/Spotlights.js @@ -64,7 +64,8 @@ export default class Spotlights extends EventEmitter index++; for (let i = 0; i < this._unmutablePeerList.length; i++) { - if (index >= this._unmutablePeerList.length) { + if (index >= this._unmutablePeerList.length) + { index = 0; } newSelectedPeer = this._unmutablePeerList[index]; @@ -75,6 +76,7 @@ export default class Spotlights extends EventEmitter index++; } } + return newSelectedPeer; } @@ -96,7 +98,8 @@ export default class Spotlights extends EventEmitter index--; for (let i = 0; i < this._unmutablePeerList.length; i++) { - if (index < 0) { + if (index < 0) + { index = this._unmutablePeerList.length - 1; } newSelectedPeer = this._unmutablePeerList[index]; @@ -107,6 +110,7 @@ export default class Spotlights extends EventEmitter index--; } } + return newSelectedPeer; }