media_player: Don't switch to first input source, if we actually know better. (#433)

* doubleCheck: Don't switch to zero, if we actually know better.

https://github.com/home-assistant/home-assistant/issues/9517

* Fix linting

* Reverting changes, introducing sourceIndexOld
This commit is contained in:
Jan Almeroth 2017-09-24 02:08:30 +02:00 committed by Paulus Schoutsen
parent ff1b667546
commit b1c83a8491

View File

@ -333,13 +333,14 @@ Polymer({
this.callService('media_next_track');
},
handleSourceChanged: function (sourceIndex) {
handleSourceChanged: function (sourceIndex, sourceIndexOld) {
var sourceInput;
// Selected Option will transition to '' before transitioning to new value
if (!this.stateObj
|| this.stateObj.attributes.source_list === undefined
|| sourceIndex < 0
|| sourceIndex >= this.stateObj.attributes.source_list.length
|| sourceIndexOld === undefined
) {
return;
}