diff --git a/bower.json b/bower.json index 3daa012e35..3d7e5a08fa 100644 --- a/bower.json +++ b/bower.json @@ -1,8 +1,8 @@ { "name": "livestreamer-twitch-gui", "dependencies": { - "ember": "2.6.2", - "ember-data": "2.6.1", + "ember": "2.7.3", + "ember-data": "2.7.0", "ember-localstorage-adapter": "bastimeyer/ember-localstorage-adapter#ember-data-2.0", "jquery": "2.1.3", "bootstrap": "3.3.1", diff --git a/src/app/components/LangFilterComponent.js b/src/app/components/LangFilterComponent.js index 8708315280..a6e8df33e9 100644 --- a/src/app/components/LangFilterComponent.js +++ b/src/app/components/LangFilterComponent.js @@ -1,23 +1,25 @@ import { get, - Binding, + defineProperty, + computed, + observer, Component } from "Ember"; import layout from "templates/components/LangFilterComponent.hbs"; +const { alias } = computed; + + export default Component.extend({ layout, tagName: "li", - init() { - this._super.apply( this, arguments ); + _checkedObserver: observer( "prop", function() { + let prop = get( this, "prop" ); + let path = `obj.${prop}`; - var prop = get( this, "prop" ); - var binding = Binding - .from( `obj.${prop}` ) - .to( "checked" ); - binding.connect( this ); - } + defineProperty( this, "checked", alias( path ) ); + }).on( "init" ) }); diff --git a/src/app/mixins/InfiniteScrollMixin.js b/src/app/mixins/InfiniteScrollMixin.js index 3499bf5ff0..76324b56c6 100644 --- a/src/app/mixins/InfiniteScrollMixin.js +++ b/src/app/mixins/InfiniteScrollMixin.js @@ -1,11 +1,16 @@ import { get, set, - Binding, + defineProperty, + computed, + observer, Mixin } from "Ember"; +const { oneWay } = computed; + + var CSSMediaRule = window.CSSMediaRule; var CSSStyleRule = window.CSSStyleRule; var reMinWidth = /^(?:\(max-width:\s*\d+px\)\s*and\s*)?\(min-width:\s*(\d+)px\)$/; @@ -111,6 +116,14 @@ export default Mixin.create({ itemSelector: "", + _offsetObserver: observer( "contentPath", function() { + let contentPath = get( this, "contentPath" ); + let path = `${contentPath}.length`; + + defineProperty( this, "offset", oneWay( path ) ); + }).on( "init" ), + + /** * Calculate how many items are needed to completely fill the container */ @@ -132,25 +145,14 @@ export default Mixin.create({ beforeModel() { this._super.apply( this, arguments ); - // reset on route change - set( this, "offset", 0 ); this.calcFetchSize(); }, setupController( controller, model ) { this._super.apply( this, arguments ); - // late bindings - var binding = get( this, "_binding_offset" ); - if ( !binding ) { - var contentPath = get( this, "contentPath" ); - binding = Binding.from( `${contentPath}.length` ).to( "offset" ); - set( this, "_binding_offset", binding ); - } - binding.connect( this ); - - var offset = get( this, "offset" ); - var limit = get( this, "limit" ); + let offset = get( this, "offset" ); + let limit = get( this, "limit" ); set( controller, "isFetching", false ); set( controller, "hasFetchedAll", offset < limit ); @@ -162,14 +164,6 @@ export default Mixin.create({ }, actions: { - "willTransition": function () { - var binding = get( this, "_binding_offset" ); - if ( binding ) { - binding.disconnect( this ); - } - return true; - }, - willFetchContent( force ) { var controller = get( this, "controller" ); var isFetching = get( controller, "isFetching" ); diff --git a/src/app/store/BooleanTransform.js b/src/app/store/BooleanTransform.js index e3fcda3398..40a468d4cd 100644 --- a/src/app/store/BooleanTransform.js +++ b/src/app/store/BooleanTransform.js @@ -1,16 +1,15 @@ import { BooleanTransform } from "EmberData"; +const defaultOptions = { allowNull: true }; + + export default BooleanTransform.reopen({ deserialize( serialized ) { - return serialized === null - ? null - : this._super( serialized ); + return this._super( serialized, defaultOptions ); }, serialize( deserialized ) { - return deserialized === null - ? null - : this._super( deserialized ); + return this._super( deserialized, defaultOptions ); } }); diff --git a/src/web_modules/Ember.js b/src/web_modules/Ember.js index 759a01c725..a7e7c3c7cd 100644 --- a/src/web_modules/Ember.js +++ b/src/web_modules/Ember.js @@ -43,6 +43,7 @@ export const LinkComponent = Ember.LinkComponent; export const Mixin = Ember.Mixin; export const EmberObject = Ember.Object; export const ObjectProxy = Ember.ObjectProxy; +export const observer = Ember.observer; export const Route = Ember.Route; export const Router = Ember.Router; export const Service = Ember.Service;