Better assign

This commit is contained in:
2018-04-07 14:03:43 +02:00
committed by Michael Bumann
parent b21d2ad864
commit 429f670c12
2 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ export default EmberObject.extend({
github_uid: null, github_uid: null,
wiki_username: null, wiki_username: null,
profileHash: null, profileHash: null,
balance: null, balance: 0,
isCore: false, isCore: false,
isCurrentUser: false, isCurrentUser: false,
+11 -11
View File
@@ -191,7 +191,7 @@ export default Service.extend({
.then(ContributorSerializer.deserialize) .then(ContributorSerializer.deserialize)
.then((attributes) => { .then((attributes) => {
debug('[kredits] loaded contributor profile', attributes); debug('[kredits] loaded contributor profile', attributes);
return Object.assign(data, attributes); return Object.assign({}, data, attributes);
}) })
.catch((err) => { .catch((err) => {
error( error(
@@ -293,28 +293,28 @@ export default Service.extend({
return this.get('ipfs') return this.get('ipfs')
.storeFile(json) .storeFile(json)
// Set profileHash
.then((profileHash) => { .then((profileHash) => {
// Set new attributes
attributes.profileHash = profileHash; attributes.profileHash = profileHash;
attributes.balance = 0; return attributes;
attributes.isCurrentUser = this.get('currentUserAccounts') })
.includes(attributes.address); .then((attributes) => {
return this.get('kreditsContract') return this.get('kreditsContract')
.then((contract) => { .then((contract) => {
let { address, isCore } = attributes; let { address, isCore, profileHash } = attributes;
let { let {
digest, hashFunction, size digest, hashFunction, size
} = this.getBytes32FromMultihash(profileHash); } = this.getBytes32FromMultihash(profileHash);
debug('[kredits] addContributor', address, digest, hashFunction, size, isCore); let contributor = [
return contract.addContributor(
address, address,
digest, digest,
hashFunction, hashFunction,
size, size,
isCore isCore,
); ];
debug('[kredits] addContributor', ...contributor);
return contract.addContributor(...contributor);
}); });
}) })
.then((data) => { .then((data) => {