persist activelights
This commit is contained in:
parent
133cf51480
commit
5121226a10
2 changed files with 22 additions and 5 deletions
|
|
@ -5,6 +5,8 @@ const {
|
|||
Component,
|
||||
computed,
|
||||
isEmpty,
|
||||
isNone,
|
||||
observer,
|
||||
$
|
||||
} = Ember;
|
||||
|
||||
|
|
@ -83,15 +85,28 @@ export default Component.extend({
|
|||
return lightsList;
|
||||
}),
|
||||
|
||||
onActiveLightsChange: observer('activeLights.[]', function(){
|
||||
this.get('storage').set('huegasm.activeLights', this.get('activeLights'));
|
||||
}),
|
||||
|
||||
init(){
|
||||
this._super(...arguments);
|
||||
|
||||
let lightsData = this.get('lightsData'),
|
||||
activeLights = this.get('activeLights');
|
||||
activeLights = this.get('activeLights'),
|
||||
activeLightsCache = this.get('storage').get('huegasm.activeLights');
|
||||
|
||||
for (let key in lightsData) {
|
||||
if (lightsData.hasOwnProperty(key) && lightsData[key].state.reachable) {
|
||||
activeLights.pushObject(key);
|
||||
if(!isNone(activeLightsCache)){
|
||||
activeLightsCache.forEach(function(i){
|
||||
if (lightsData.hasOwnProperty(i) && lightsData[i].state.reachable) {
|
||||
activeLights.pushObject(i);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (let key in lightsData) {
|
||||
if (lightsData.hasOwnProperty(key) && lightsData[key].state.reachable) {
|
||||
activeLights.pushObject(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ export default Component.extend(helperMixin, visualizerMixin, {
|
|||
}),
|
||||
|
||||
updatePageTitle: observer('playQueuePointer', function(){
|
||||
let title = 'Huegasm', playQueuePointer = this.get('playQueuePointer'), playQueue = this.get('playQueue');
|
||||
let title = 'Huegasm',
|
||||
playQueuePointer = this.get('playQueuePointer'),
|
||||
playQueue = this.get('playQueue');
|
||||
|
||||
if(playQueuePointer !== -1){
|
||||
let song = playQueue[playQueuePointer];
|
||||
|
|
|
|||
Reference in a new issue