Fix WSPeers should disconnect on 'peer-left' message, indifferent from 'disconnect' flag

This commit is contained in:
schlagmichdoch 2024-02-22 17:43:11 +01:00
parent 07e46e472e
commit 52198c7efb

View file

@ -1615,20 +1615,23 @@ class PeersManager {
if (this._peerExists(message.peerId) && !this._webRtcSupported(message.peerId)) { if (this._peerExists(message.peerId) && !this._webRtcSupported(message.peerId)) {
Logger.debug('WSPeer left:', message.peerId); Logger.debug('WSPeer left:', message.peerId);
} }
if (message.disconnect === true) { else if (message.disconnect !== true) {
// if user actively disconnected from PairDrop server, disconnect all peer to peer connections immediately // if RTCPeer and disconnect is false -> abort and wait for reconnect
this._disconnectOrRemoveRoomTypeByPeerId(message.peerId, message.roomType); return;
}
// If no peers are connected anymore, we can safely assume that no other tab on the same browser is connected: // if user actively disconnected from PairDrop server or is WSPeer, disconnect all peer to peer connections immediately
// Tidy up peerIds in localStorage this._disconnectOrRemoveRoomTypeByPeerId(message.peerId, message.roomType);
if (Object.keys(this.peers).length === 0) {
BrowserTabsConnector // If no peers are connected anymore, we can safely assume that no other tab on the same browser is connected:
.removeOtherPeerIdsFromLocalStorage() // Tidy up peerIds in localStorage
.then(peerIds => { if (Object.keys(this.peers).length === 0) {
if (!peerIds) return; BrowserTabsConnector
Logger.debug("successfully removed other peerIds from localStorage"); .removeOtherPeerIdsFromLocalStorage()
}); .then(peerIds => {
} if (!peerIds) return;
Logger.debug("successfully removed other peerIds from localStorage");
});
} }
} }