From 2157328f065454e187ef0931b373338ce3e4514f Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 9 Oct 2015 03:40:17 -0700 Subject: [PATCH] fixing some bugs --- .../components/bridge-finder/component.js | 4 +-- app/pods/components/hue-controls/component.js | 18 ++++++----- app/pods/components/hue-controls/template.hbs | 2 +- app/pods/components/music-tab/component.js | 18 +++++------ .../components/music-tab/mixins/music-tab.js | 4 +++ app/pods/components/music-tab/template.hbs | 2 +- app/styles/app.scss | 30 +++++++------------ 7 files changed, 38 insertions(+), 40 deletions(-) diff --git a/app/pods/components/bridge-finder/component.js b/app/pods/components/bridge-finder/component.js index 9a3e463..98d2219 100644 --- a/app/pods/components/bridge-finder/component.js +++ b/app/pods/components/bridge-finder/component.js @@ -96,13 +96,13 @@ export default Em.Component.extend({ // try to authenticate against the bridge here onBridgeIpChange: function () { - if(!this.get('trial')) { + if(!this.get('trial') && !this.get('isAuthenticating')) { this.setProperties({ bridgePingIntervalHandle: setInterval(this.pingBridgeUser.bind(this), this.get('bridgeUsernamePingIntervalTime')), bridgeUserNamePingIntervalProgress: 0 }); } - }.observes('bridgeIp'), + }.observes('bridgeIp').on('init'), pingBridgeUser() { var bridgeIp = this.get('bridgeIp'), self = this, bridgeUserNamePingIntervalProgress = this.get('bridgeUserNamePingIntervalProgress'), diff --git a/app/pods/components/hue-controls/component.js b/app/pods/components/hue-controls/component.js index bae4dd4..e18a9aa 100644 --- a/app/pods/components/hue-controls/component.js +++ b/app/pods/components/hue-controls/component.js @@ -105,6 +105,8 @@ export default Em.Component.extend({ lightsTabSelected: Em.computed.equal('selectedTab', 0), musicTabSelected: Em.computed.equal('selectedTab', 1), + pauseLightUpdates: false, + updateLightData(){ var self = this, fail = function() { clearInterval(self.get('lightsDataIntervalHandle')); @@ -114,13 +116,15 @@ export default Em.Component.extend({ }); }; - Em.$.get(this.get('apiURL') + '/lights', function (result, status) { - if (status === 'success' && Em.isNone(result[0])) { - self.set('lightsData', result); - } else { - fail(); - } - }).fail(fail); + if(!this.get('pauseLightUpdates')){ + Em.$.get(this.get('apiURL') + '/lights', function (result, status) { + if(!Em.isNone(result[0]) && !Em.isNone(result[0].error)){ + fail(); + } else if (status === 'success' && JSON.stringify(self.get('lightsData')) !== JSON.stringify(result)) { + self.set('lightsData', result); + } + }).fail(fail); + } }, ready: function() { diff --git a/app/pods/components/hue-controls/template.hbs b/app/pods/components/hue-controls/template.hbs index 92269ea..29e5d13 100644 --- a/app/pods/components/hue-controls/template.hbs +++ b/app/pods/components/hue-controls/template.hbs @@ -33,5 +33,5 @@ {{lights-tab apiURL=apiURL lightsData=lightsData activeLights=activeLights trial=trial active=lightsTabSelected}} - {{music-tab apiURL=apiURL lightsData=lightsData activeLights=activeLights active=musicTabSelected}} + {{music-tab apiURL=apiURL lightsData=lightsData activeLights=activeLights active=musicTabSelected pauseLightUpdates=pauseLightUpdates}} {{/if}} \ No newline at end of file diff --git a/app/pods/components/music-tab/component.js b/app/pods/components/music-tab/component.js index d0d10fb..f013467 100644 --- a/app/pods/components/music-tab/component.js +++ b/app/pods/components/music-tab/component.js @@ -83,10 +83,10 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { defaultControls(){ var beatOptions = this.get('beatOptions'); - this.changePlayerControl('threshold', beatOptions.threshold.defaultValue, true); - this.changePlayerControl('decay', beatOptions.decay.defaultValue, true); - this.changePlayerControl('frequency', beatOptions.frequency.defaultValue, true); - this.changePlayerControl('transitionTime', beatOptions.transitionTime.defaultValue, true); + this.changePlayerControl('threshold', beatOptions.threshold.defaultValue, true, true); + this.changePlayerControl('decay', beatOptions.decay.defaultValue, true, true); + this.changePlayerControl('frequency', beatOptions.frequency.defaultValue, true, true); + this.changePlayerControl('transitionTime', beatOptions.transitionTime.defaultValue, true, true); }, playerAreaPlay(){ if(Em.isEmpty(Em.$('#playerControls:hover')) && this.get('playQueuePointer') !== -1 ){ @@ -142,7 +142,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { this.changePlayerControl('volumeMuted', false); } }, - next() { + next(userTriggered) { var playQueuePointer = this.get('playQueuePointer'), playQueueLength = this.get('playQueue.length'); var nextSong = (playQueuePointer + 1), repeat = this.get('repeat'); @@ -151,7 +151,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { if(repeat === 2){ this.send('goToSong', playQueuePointer, true); } else if(nextSong > playQueueLength-1){ - if(repeat === 1){ + if(repeat === 1 || userTriggered){ nextSong = nextSong % playQueueLength; } else { this.send('play', true); @@ -311,7 +311,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { songBeatPreferences[title] = {threshold: this.get('threshold'), decay: this.get('decay'), frequency: this.get('frequency') }; this.set('usingBeatPreferences', true); - this.get('storage').set('huegasm.songBeatPreferences', songBeatPreferences); + this.get('storage').set('huegasm.songBeatPreferences', songBeatPreferences, { compress: true }); }, loadSongBeatPreferences() { @@ -503,7 +503,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { this._super(); var dancer = new Dancer(), - storage = new window.Locally.Store({compress: true}), + storage = new window.Locally.Store(), self = this, threshold = this.get('threshold'), decay = this.get('decay'), @@ -554,7 +554,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { } ['volume', 'shuffle', 'repeat', 'volumeMuted', 'threshold', 'decay', 'frequency', 'speakerViewed', 'transitionTime', 'randomTransition', 'playerBottomDisplayed', 'onBeatBriAndColor', 'audioMode', 'dimmerEnabled', 'songBeatPreferences'].forEach(function (item) { - if (storage.get('huegasm.' + item)) { + if (!Em.isNone(storage.get('huegasm.' + item))) { var itemVal = storage.get('huegasm.' + item); if(Em.isNone(self.actions[item+'Changed'])){ diff --git a/app/pods/components/music-tab/mixins/music-tab.js b/app/pods/components/music-tab/mixins/music-tab.js index 3b950a5..5e19456 100644 --- a/app/pods/components/music-tab/mixins/music-tab.js +++ b/app/pods/components/music-tab/mixins/music-tab.js @@ -126,6 +126,10 @@ export default Em.Mixin.create({ oldBeatPrefCache: null, storage: null, + pauseLightUpdates: function(){ + return this.get('playing'); + }.property('playing'), + speakerViewed: true, speakerLabel: function() { if(this.get('speakerViewed')){ diff --git a/app/pods/components/music-tab/template.hbs b/app/pods/components/music-tab/template.hbs index 93064d1..025aa2f 100644 --- a/app/pods/components/music-tab/template.hbs +++ b/app/pods/components/music-tab/template.hbs @@ -13,7 +13,7 @@ data-title={{playingTooltipTxt}} {{action "play"}}>{{paper-icon icon=playingIcon class="playerControllIcon"}}{{#if playQueueMultiple}}{{paper-icon icon="skip-next" action="" class="playerControllIcon"}}{{/if}}{{paper-icon icon=volumeIcon class=volumeMutedClass}}