From afa09f4b8f9fb8518a07de9ac954639031b22cd2 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sat, 27 Apr 2019 17:33:25 +0100 Subject: [PATCH] Move computed collections to kredits service They should be available from any place with access to the service. --- app/controllers/index.js | 16 +++------------- app/services/kredits.js | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/controllers/index.js b/app/controllers/index.js index 825a03d..2c947fd 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -1,7 +1,6 @@ import Controller from '@ember/controller'; import { alias, filter, sort } from '@ember/object/computed'; import { inject as service } from '@ember/service'; -import { computed } from '@ember/object'; export default Controller.extend({ kredits: service(), @@ -15,21 +14,12 @@ export default Controller.extend({ contributorsSorted: sort('contributorsWithKredits', 'contributorsSorting'), contributions: alias('kredits.contributions'), - contributionsSorting: Object.freeze(['id:desc']), - - contributionsUnconfirmed: computed('contributions.[]', 'currentBlock', function() { - return this.contributions.filter(contribution => { - return contribution.confirmedAt > this.currentBlock; - }); - }), - contributionsConfirmed: computed('contributions.[]', 'currentBlock', function() { - return this.contributions.filter(contribution => { - return contribution.confirmedAt <= this.currentBlock; - }); - }), + contributionsUnconfirmed: alias('kredits.contributionsUnconfirmed'), + contributionsConfirmed: alias('kredits.contributionsConfirmed'), contributionsUnconfirmedSorted: sort('contributionsUnconfirmed', 'contributionsSorting'), contributionsConfirmedSorted: sort('contributionsConfirmed', 'contributionsSorting'), + contributionsSorting: Object.freeze(['id:desc']), actions: { diff --git a/app/services/kredits.js b/app/services/kredits.js index 12cd42c..acef3a0 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -20,15 +20,29 @@ export default Service.extend({ currentUserAccounts: null, // default to not having an account. this is the wen web3 is loaded. currentUser: null, contributors: null, - proposals: null, contributions: null, + proposals: null, + currentUserIsContributor: notEmpty('currentUser'), currentUserIsCore: alias('currentUser.isCore'), hasAccounts: notEmpty('currentUserAccounts'), + accountNeedsUnlock: computed('currentUserAccounts', function() { return this.currentUserAccounts && isEmpty(this.currentUserAccounts); }), + contributionsUnconfirmed: computed('contributions.[]', 'currentBlock', function() { + return this.contributions.filter(contribution => { + return contribution.confirmedAt > this.currentBlock; + }); + }), + + contributionsConfirmed: computed('contributions.[]', 'currentBlock', function() { + return this.contributions.filter(contribution => { + return contribution.confirmedAt <= this.currentBlock; + }); + }), + init () { this._super(...arguments); this.set('contributors', []);