Skip to content

Commit

Permalink
Update to Ember/EmberData 2.7 and fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Sep 9, 2016
1 parent b338a6b commit 70b1426
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 39 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
20 changes: 11 additions & 9 deletions src/app/components/LangFilterComponent.js
Original file line number Diff line number Diff line change
@@ -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" )
});
38 changes: 16 additions & 22 deletions src/app/mixins/InfiniteScrollMixin.js
Original file line number Diff line number Diff line change
@@ -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\)$/;
Expand Down Expand Up @@ -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
*/
Expand All @@ -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 );
Expand All @@ -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" );
Expand Down
11 changes: 5 additions & 6 deletions src/app/store/BooleanTransform.js
Original file line number Diff line number Diff line change
@@ -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 );
}
});
1 change: 1 addition & 0 deletions src/web_modules/Ember.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 70b1426

Please sign in to comment.