Reduce indentation waterfall

This commit is contained in:
Corey Frang 2018-04-05 14:42:35 -04:00 committed by Michael "Z" Goddard
parent f3a956af2b
commit 9cd5e4da2b
No known key found for this signature in database
GPG key ID: 762CD40DD5349872

View file

@ -100,12 +100,21 @@ class Video {
*/
disableVideo () {
this.enabled = false;
// If we have begun a setup process, wait for it to complete
// If we have begun a setup process, call _teardown after it completes
if (this._singleSetup) {
this._singleSetup
.then(() => {
// we might be asked to re-enable before setup completes
if (!this.enabled) {
.then(this._teardown.bind(this))
.catch(() => {});
}
}
/**
* async part of disableVideo
* @private
*/
_teardown () {
// we might be asked to re-enable before _teardown is called, just ignore it.
if (this.enabled === false) {
this._disablePreview();
this._singleSetup = null;
// by clearing refs to video and track, we should lose our hold over the camera
@ -115,9 +124,6 @@ class Video {
}
this._track = null;
}
})
.catch(() => {});
}
}
/**