Skip to content

Commit

Permalink
Fix computed property overridability deprecation warnings (#68)
Browse files Browse the repository at this point in the history
* Fix computed property overidability deprecation warnings

* Update initials.js
  • Loading branch information
Sabin Hertanu authored and Exelord committed Apr 23, 2019
1 parent b16eb16 commit b9fc6b4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
24 changes: 18 additions & 6 deletions addon/mixins/initials.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,24 @@ export default Mixin.create(Avatar, {
this.notifyPropertyChange('src');
}),

backgroundColor: computed('colors.length', 'seedText', 'defaultName', 'defaultBackground', function () {
if (this.get('seedText') === this.get('defaultName')) {
return this.get('defaultBackground');
} else {
let index = ColorIndex(this.get('seedText'), this.get('colors.length'));
return this.get('colors')[index];
backgroundColor: computed('colors.length', 'seedText', 'defaultName', 'defaultBackground', {
get() {
if (this._backgroundColor) {
return this._backgroundColor;
}

let { colors, seedText, defaultName, defaultBackground } = this;

if (seedText === defaultName) {
return defaultBackground;
} else {
let index = ColorIndex(seedText, colors.length);
return colors[index];
}
},

set(key, value) {
return this._backgroundColor = value;
}
}),

Expand Down
45 changes: 33 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b9fc6b4

Please sign in to comment.