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:
parent
9788390139
commit
e881261ce1
@ -7,9 +7,10 @@ var Events = can.Construct.extend({
|
|||||||
|
|
||||||
this.events.onmessage = function(e) {
|
this.events.onmessage = function(e) {
|
||||||
response = JSON.parse(e.data);
|
response = JSON.parse(e.data);
|
||||||
|
console.log(response.data);
|
||||||
switch (response.type) {
|
switch (response.type) {
|
||||||
case 'status':
|
case 'status':
|
||||||
status.attr(response.data);
|
status.attr(response.data, true);
|
||||||
break;
|
break;
|
||||||
case 'queue':
|
case 'queue':
|
||||||
queue.replace(response.data);
|
queue.replace(response.data);
|
||||||
@ -19,7 +20,7 @@ var Events = can.Construct.extend({
|
|||||||
|
|
||||||
status.bind('change', function(event, attr, how, newVal, oldVal) {
|
status.bind('change', function(event, attr, how, newVal, oldVal) {
|
||||||
if (attr == 'song') {
|
if (attr == 'song') {
|
||||||
queue.updatePlaying(oldVal, newVal);
|
queue.updatePlaying(how, newVal, oldVal);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@ -6,9 +6,13 @@ var QueueSong = can.Model.extend({
|
|||||||
|
|
||||||
QueueSong.List = can.List.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);
|
this.attr(oldVal).attr('playing', false);
|
||||||
|
}
|
||||||
|
if (how == 'add' || how == 'set') {
|
||||||
this.attr(newVal).attr('playing', true);
|
this.attr(newVal).attr('playing', true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user