Merge pull request #3656 from tgxworld/ember-computed-property

FIX: Wrong value set when using ember-computed-decorators.
This commit is contained in:
Régis Hanol 2015-08-14 18:23:10 +02:00
commit 5a09482b0f
3 changed files with 10 additions and 22 deletions

View File

@ -28,12 +28,11 @@ export default Ember.Component.extend(BufferedContent, ScrollTop, {
@computed('buffered.value') @computed('buffered.value')
enabled: { enabled: {
get() { get(bufferedValue) {
const bufferedValue = this.get('buffered.value');
if (Ember.isEmpty(bufferedValue)) { return false; } if (Ember.isEmpty(bufferedValue)) { return false; }
return bufferedValue === 'true'; return bufferedValue === 'true';
}, },
set(key, value) { set(value) {
this.set('buffered.value', value ? 'true' : 'false'); this.set('buffered.value', value ? 'true' : 'false');
} }
}, },

View File

@ -11,10 +11,8 @@ export default Ember.Component.extend({
@computed @computed
notificationsDisabled: { notificationsDisabled: {
set(key, value) { set(value) {
if (arguments.length > 1) { localStorage.setItem('notifications-disabled', value);
localStorage.setItem('notifications-disabled', value);
}
return localStorage.getItem('notifications-disabled'); return localStorage.getItem('notifications-disabled');
}, },
get() { get() {

View File

@ -68,13 +68,10 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
@computed('model.postStream.summary') @computed('model.postStream.summary')
show_deleted: { show_deleted: {
set(key, value) { set(value) {
const postStream = this.get('model.postStream'); const postStream = this.get('model.postStream');
if (!postStream) { return; } if (!postStream) { return; }
postStream.set('show_deleted', value);
if (arguments.length > 1) {
postStream.set('show_deleted', value);
}
return postStream.get('show_deleted') ? true : undefined; return postStream.get('show_deleted') ? true : undefined;
}, },
get() { get() {
@ -84,13 +81,10 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
@computed('model.postStream.summary') @computed('model.postStream.summary')
filter: { filter: {
set(key, value) { set(value) {
const postStream = this.get('model.postStream'); const postStream = this.get('model.postStream');
if (!postStream) { return; } if (!postStream) { return; }
postStream.set('summary', value === "summary");
if (arguments.length > 1) {
postStream.set('summary', value === "summary");
}
return postStream.get('summary') ? "summary" : undefined; return postStream.get('summary') ? "summary" : undefined;
}, },
get() { get() {
@ -100,13 +94,10 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
@computed('model.postStream.streamFilters.username_filters') @computed('model.postStream.streamFilters.username_filters')
username_filters: { username_filters: {
set(key, value) { set(value) {
const postStream = this.get('model.postStream'); const postStream = this.get('model.postStream');
if (!postStream) { return; } if (!postStream) { return; }
postStream.set('streamFilters.username_filters', value);
if (arguments.length > 1) {
postStream.set('streamFilters.username_filters', value);
}
return postStream.get('streamFilters.username_filters'); return postStream.get('streamFilters.username_filters');
}, },
get() { get() {