1
0
mirror of https://github.com/danbee/mpd-client synced 2025-03-04 08:39:09 +00:00

Fix some bugs around setting of playing status.

This commit is contained in:
Dan Barber 2013-12-07 16:58:03 +00:00
parent 9788390139
commit e881261ce1
2 changed files with 10 additions and 5 deletions

View File

@ -7,9 +7,10 @@ var Events = can.Construct.extend({
this.events.onmessage = function(e) {
response = JSON.parse(e.data);
console.log(response.data);
switch (response.type) {
case 'status':
status.attr(response.data);
status.attr(response.data, true);
break;
case 'queue':
queue.replace(response.data);
@ -19,7 +20,7 @@ var Events = can.Construct.extend({
status.bind('change', function(event, attr, how, newVal, oldVal) {
if (attr == 'song') {
queue.updatePlaying(oldVal, newVal);
queue.updatePlaying(how, newVal, oldVal);
}
});
},

View File

@ -6,9 +6,13 @@ var QueueSong = can.Model.extend({
QueueSong.List = can.List.extend({
updatePlaying: function(oldVal, newVal) {
updatePlaying: function(how, newVal, oldVal) {
if ((how == 'remove' || how == 'set') && this.attr(oldVal) != undefined) {
this.attr(oldVal).attr('playing', false);
}
if (how == 'add' || how == 'set') {
this.attr(newVal).attr('playing', true);
}
}
});