From e2a944ed5b7bc94094c71f7b4eef40c4eb5d1624 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sat, 16 May 2020 13:21:02 +0200 Subject: [PATCH 01/10] Update schemas package Use the new one from the org namespace. --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c36079..215d5a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2219,6 +2219,15 @@ "integrity": "sha512-i01plR0EgFVz69GDrEuFgq1NheIjZcyTy3c7q+w7d096ddPVeVcRzU3LKaqCfovvLJ+6lJx40j45ecycASUUyw==", "dev": true }, + "@kosmos/schemas": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@kosmos/schemas/-/schemas-2.2.1.tgz", + "integrity": "sha512-zYUctQ91sYhzoJ0ujO73odBSsnwvdLlS6ENA/U/4/IzRKVZBj9cS4RpgFh1xOQXNN+HB4pUu8u7Su/Xtked+vg==", + "dev": true, + "requires": { + "brfs-babel": "^1.0.0" + } + }, "@nodelib/fs.scandir": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz", @@ -16569,15 +16578,6 @@ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, - "kosmos-schemas": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/kosmos-schemas/-/kosmos-schemas-2.1.0.tgz", - "integrity": "sha512-RT90o0ujAKoCUpcYHi5ijDxg9F9enY5aOIZXujidjkCQ/hgjJ2tyNi+x8rszutsAP/mx64yj307oWJWhNZTyTg==", - "dev": true, - "requires": { - "brfs-babel": "^1.0.0" - } - }, "kredits-contracts": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/kredits-contracts/-/kredits-contracts-5.5.0.tgz", diff --git a/package.json b/package.json index e87aa72..edf0662 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@ember/optional-features": "^1.3.0", "@glimmer/component": "^1.0.0", "@glimmer/tracking": "^1.0.0", + "@kosmos/schemas": "^2.2.1", "babel-eslint": "^10.1.0", "babel-preset-es2015": "^6.22.0", "babelify": "^7.3.0", @@ -64,7 +65,6 @@ "eslint-plugin-ember": "^8.4.0", "eslint-plugin-node": "^11.1.0", "ethers": "^4.0.47", - "kosmos-schemas": "^2.1.0", "kredits-contracts": "^5.5.0", "loader.js": "^4.7.0", "ndjson": "github:hugomrdias/ndjson#feat/readable-stream3", -- 2.50.1 From 352c9fe3ab385f7049e36ed80af0a3c5a05644f6 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 27 May 2020 11:15:42 +0200 Subject: [PATCH 02/10] Add new contribution types --- app/components/add-contribution/template.hbs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/components/add-contribution/template.hbs b/app/components/add-contribution/template.hbs index ab7b930..05ce592 100644 --- a/app/components/add-contribution/template.hbs +++ b/app/components/add-contribution/template.hbs @@ -15,11 +15,14 @@

-- 2.50.1 From 1d8e9ddf5d7fc1408610ecc2c9842b63cb9b1411 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 27 May 2020 11:19:23 +0200 Subject: [PATCH 03/10] Remove obsolete npm cache Travis config It's cached by default now --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index db3b0cc..08a589c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,10 +14,6 @@ notifications: addons: chrome: stable -cache: - directories: - - $HOME/.npm - env: global: # See https://git.io/vdao3 for details. -- 2.50.1 From bf6d9dbc31cf01f900a627234f836326180c82c0 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 29 May 2020 13:11:36 +0200 Subject: [PATCH 04/10] Remove RSVP from kredits service Just native Promise will do. --- app/services/kredits.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/services/kredits.js b/app/services/kredits.js index c33b347..73d0d9b 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -1,6 +1,5 @@ import ethers from 'ethers'; import Kredits from 'kredits-contracts'; -import RSVP from 'rsvp'; import Service from '@ember/service'; import EmberObject from '@ember/object'; @@ -90,7 +89,7 @@ export default Service.extend({ getEthProvider () { let ethProvider; - return new RSVP.Promise(async (resolve) => { + return new Promise(async (resolve) => { function instantiateWithoutAccount () { console.debug('[kredits] Creating new instance from npm module class'); console.debug(`[kredits] providerURL: ${config.web3ProviderUrl}`); @@ -323,14 +322,14 @@ export default Service.extend({ getCurrentUser: computed('kredits.provider', 'currentUserAccounts.[]', function() { if (isEmpty(this.currentUserAccounts)) { - return RSVP.resolve(); + return Promise.resolve(); } return this.kredits.Contributor .functions.getContributorIdByAddress(this.currentUserAccounts.firstObject) .then((id) => { // check if the user is a contributor or not if (id === 0) { - return RSVP.resolve(); + return Promise.resolve(); } else { return this.kredits.Contributor.getById(id); } -- 2.50.1 From eb2c613ac99caa0b55a2ad9f3ab3a4e9ee485d57 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 29 May 2020 13:12:39 +0200 Subject: [PATCH 05/10] Extract data loading from fetch methods --- app/services/kredits.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/app/services/kredits.js b/app/services/kredits.js index 73d0d9b..7a50bf5 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -225,12 +225,9 @@ export default Service.extend({ console.debug(`[kredits] Fetching all contributors from the network`); return this.kredits.Contributor.all() .then(contributors => { - return contributors.map(data => { - const contributor = Contributor.create(processContributorData(data)); - const loadedContributor = this.contributors.findBy('id', contributor.id); - if (loadedContributor) { this.contributors.removeObject(loadedContributor); } - this.contributors.pushObject(contributor); - return contributor; + return contributors.forEach(data => { + this.loadContributorFromData(data); + return; }); }) .then(() => { @@ -238,6 +235,13 @@ export default Service.extend({ }); }, + loadContributorFromData(data) { + const contributor = Contributor.create(processContributorData(data)); + const loadedContributor = this.contributors.findBy('id', contributor.id); + if (loadedContributor) { this.contributors.removeObject(loadedContributor); } + this.contributors.pushObject(contributor); + }, + async cacheLoadedContributors () { for (const c of this.contributors) { await this.browserCache.contributors.setItem(c.id, c.serialize()); @@ -274,11 +278,7 @@ export default Service.extend({ return this.kredits.Contribution.all(options) .then(contributions => { return contributions.map(data => { - const contribution = Contribution.create(processContributionData(data)); - contribution.set('contributor', this.contributors.findBy('id', data.contributorId.toString())); - const loadedContribution = this.contributions.findBy('id', contribution.id); - if (loadedContribution) { this.contributions.removeObject(loadedContribution); } - this.contributions.pushObject(contribution); + loadContributionFromData(data); return contribution; }); }) @@ -292,6 +292,14 @@ export default Service.extend({ }); }, + loadContributionFromData(data) { + const contribution = Contribution.create(processContributionData(data)); + contribution.set('contributor', this.contributors.findBy('id', data.contributorId.toString())); + const loadedContribution = this.contributions.findBy('id', contribution.id); + if (loadedContribution) { this.contributions.removeObject(loadedContribution); } + this.contributions.pushObject(contribution); + }, + async cacheLoadedContributions () { for (const c of this.contributions) { await this.browserCache.contributions.setItem(c.id, c.serialize()); -- 2.50.1 From 63dd5430bc1ad52d20b19e528df9ba572554b56c Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 29 May 2020 13:13:21 +0200 Subject: [PATCH 06/10] WIP Sync contributions --- app/components/contribution-list/template.hbs | 2 +- app/components/contributor-list/component.js | 5 +- app/components/contributor-list/template.hbs | 46 ++++++++++--------- app/routes/application.js | 6 ++- app/services/kredits.js | 45 +++++++++++++++++- app/styles/_sugar.scss | 17 +++++++ app/styles/app.scss | 1 + app/styles/components/_contribution-list.scss | 9 ++++ app/styles/components/_contributor-list.scss | 8 ++++ app/templates/dashboard.hbs | 10 ++-- package-lock.json | 11 +++++ package.json | 1 + 12 files changed, 129 insertions(+), 32 deletions(-) create mode 100644 app/styles/_sugar.scss diff --git a/app/components/contribution-list/template.hbs b/app/components/contribution-list/template.hbs index 87d2349..42280a2 100644 --- a/app/components/contribution-list/template.hbs +++ b/app/components/contribution-list/template.hbs @@ -29,7 +29,7 @@ {{/if}} -
    +
      {{#each this.contributionsFiltered as |contribution|}}
    • - {{#each @contributorList as |c|}} - - - {{c.contributor.name}} - - - - {{#if @showUnconfirmedKredits}} - {{c.amountTotal}} - {{else}} - {{c.amountConfirmed}} - {{/if}} - - ₭S - - - {{/each}} - + + + + + {{#each @contributorList as |c|}} + + + + + {{/each}} + +
      + {{c.contributor.name}} + + + {{#if @showUnconfirmedKredits}} + {{c.amountTotal}} + {{else}} + {{c.amountConfirmed}} + {{/if}} + + ₭S +
      diff --git a/app/routes/application.js b/app/routes/application.js index b5fdfc9..f5ecd51 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -25,9 +25,11 @@ export default Route.extend({ }) .then(() => { if (this.kredits.contributorsNeedFetch) { - schedule('afterRender', this.kredits, this.kredits.fetchContributors); + schedule('afterRender', this.kredits.syncContributors, + this.kredits.syncContributors.perform); } - schedule('afterRender', this.kredits, this.kredits.fetchContributions); + schedule('afterRender', this.kredits.syncContributions, + this.kredits.syncContributions.perform); }); } }); diff --git a/app/services/kredits.js b/app/services/kredits.js index 7a50bf5..c0b5117 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -8,6 +8,8 @@ import { alias, notEmpty } from '@ember/object/computed'; import { isEmpty, isPresent } from '@ember/utils'; import { inject as service } from '@ember/service'; +import { task } from 'ember-concurrency'; + import groupBy from 'kredits-web/utils/group-by'; import processContributorData from 'kredits-web/utils/process-contributor-data'; import processContributionData from 'kredits-web/utils/process-contribution-data'; @@ -240,6 +242,7 @@ export default Service.extend({ const loadedContributor = this.contributors.findBy('id', contributor.id); if (loadedContributor) { this.contributors.removeObject(loadedContributor); } this.contributors.pushObject(contributor); + return contributor; }, async cacheLoadedContributors () { @@ -258,6 +261,10 @@ export default Service.extend({ }); }, + syncContributors: task(function * () { + yield this.fetchContributors(); + }), + addContribution (attributes) { console.debug('[kredits] add contribution', attributes); @@ -278,7 +285,7 @@ export default Service.extend({ return this.kredits.Contribution.all(options) .then(contributions => { return contributions.map(data => { - loadContributionFromData(data); + const contribution = this.loadContributionFromData(data); return contribution; }); }) @@ -298,6 +305,7 @@ export default Service.extend({ const loadedContribution = this.contributions.findBy('id', contribution.id); if (loadedContribution) { this.contributions.removeObject(loadedContribution); } this.contributions.pushObject(contribution); + return contribution; }, async cacheLoadedContributions () { @@ -316,6 +324,41 @@ export default Service.extend({ }); }, + syncContributions: task(function * () { + yield this.fetchNewContributions.perform(); + yield this.syncUnconfirmedContributions.perform(); + }), + + fetchNewContributions: task(function * () { + const count = yield this.kredits.Contribution.functions.contributionsCount(); + const lastKnownContributionId = Math.max.apply(null, this.contributions.mapBy('id')); + const toFetch = count - lastKnownContributionId; + + if (toFetch > 0) { + console.debug(`[kredits] Fetching ${toFetch} new contributions`); + for (let id = lastKnownContributionId; id <= count; id++) { + const data = yield this.kredits.Contribution.getById(id); + const c = this.loadContributionFromData(data); + yield this.browserCache.contributions.setItem(c.id.toString(), c.serialize()); + } + } else { + console.debug(`[kredits] No new contributions to fetch`); + } + }), + + syncUnconfirmedContributions: task(function * () { + if (this.contributionsUnconfirmed.length > 0) { + console.debug(`[kredits] Syncing unconfirmed contributions`); + for (const c of this.contributionsUnconfirmed) { + const data = yield this.kredits.Contribution.getById(c.id); + const contribution = this.loadContributionFromData(data); + yield this.browserCache.contributions.setItem(c.id.toString(), contribution.serialize()); + } + } else { + console.debug(`[kredits] No unconfirmed contributions to sync`); + } + }), + veto (contributionId) { console.debug('[kredits] veto against', contributionId); const contribution = this.contributions.findBy('id', contributionId); diff --git a/app/styles/_sugar.scss b/app/styles/_sugar.scss new file mode 100644 index 0000000..00033ca --- /dev/null +++ b/app/styles/_sugar.scss @@ -0,0 +1,17 @@ +@mixin loading-border-top { + &::before { + display: block; + width: 100%; + height: 1px; + content: ''; + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 40%, #68d7fb 60%, rgba(255, 255, 255, 0.2)); + background-size: 200% 200%; + animation: kitt 2.5s linear infinite; + } +} + +@keyframes kitt { + 0%{ background-position: 0% 0%} + 50%{ background-position: 100% 0%} + 100%{ background-position: 0% 0%} +} diff --git a/app/styles/app.scss b/app/styles/app.scss index 364dd7a..97112ac 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -88,6 +88,7 @@ section { @import "buttons"; @import "forms"; +@import "sugar"; @import "components/contribution-list"; @import "components/contribution-details"; diff --git a/app/styles/components/_contribution-list.scss b/app/styles/components/_contribution-list.scss index 9cfee0e..bb560e6 100644 --- a/app/styles/components/_contribution-list.scss +++ b/app/styles/components/_contribution-list.scss @@ -114,4 +114,13 @@ ul.contribution-list { } } + &.loading { + @include loading-border-top; + + li { + &:first-of-type { + border-top: none; + } + } + } } diff --git a/app/styles/components/_contributor-list.scss b/app/styles/components/_contributor-list.scss index e35419d..2d56780 100644 --- a/app/styles/components/_contributor-list.scss +++ b/app/styles/components/_contributor-list.scss @@ -1,4 +1,5 @@ table.contributor-list { + position: relative; width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; @@ -48,4 +49,11 @@ table.contributor-list { } } } + + &.loading { + @include loading-border-top; + &::before { + position: absolute; + } + } } diff --git a/app/templates/dashboard.hbs b/app/templates/dashboard.hbs index 1f9e22d..0235455 100644 --- a/app/templates/dashboard.hbs +++ b/app/templates/dashboard.hbs @@ -29,7 +29,8 @@
      + @selectedContributorId={{this.selectedContributorId}} + @loading={{this.kredits.syncContributors.isRunning}} />

      {{await this.kredits.totalKreditsEarned}} kredits confirmed and issued to @@ -58,7 +59,9 @@ {{#if this.contributionsUnconfirmed}}

      -

      Latest Contributions

      +

      + Latest Contributions +

      {{/if}} diff --git a/package-lock.json b/package-lock.json index aaac05a..c919e8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10259,6 +10259,17 @@ "semver": "^5.4.1" } }, + "ember-concurrency": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/ember-concurrency/-/ember-concurrency-1.1.7.tgz", + "integrity": "sha512-PtEJvB4wG8e5CEHRC9ILl2BxF6U/xlMOhfCji/x7FxNFB9M230Du86LAy+4/yOozZHyoARVuazABPUj02P+DmQ==", + "dev": true, + "requires": { + "ember-cli-babel": "^7.7.3", + "ember-compatibility-helpers": "^1.2.0", + "ember-maybe-import-regenerator": "^0.1.6" + } + }, "ember-diff-attrs": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/ember-diff-attrs/-/ember-diff-attrs-0.2.2.tgz", diff --git a/package.json b/package.json index 3ec4ec6..2d5b8ae 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "ember-cli-sass": "^10.0.1", "ember-cli-sri": "^2.1.1", "ember-cli-uglify": "^3.0.0", + "ember-concurrency": "^1.1.7", "ember-export-application-global": "^2.0.1", "ember-fetch": "^8.0.1", "ember-flatpickr": "^2.16.2", -- 2.50.1 From c54d754c8979b33cea2d2672e939535e209c2a07 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 29 May 2020 20:55:19 +0200 Subject: [PATCH 07/10] Only sync contributions if loaded from cache --- app/routes/application.js | 8 +++++--- app/services/kredits.js | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/routes/application.js b/app/routes/application.js index f5ecd51..3aec684 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -24,12 +24,14 @@ export default Route.extend({ this.kredits.addContractEventHandlers(); }) .then(() => { - if (this.kredits.contributorsNeedFetch) { + if (this.kredits.contributorsNeedSync) { schedule('afterRender', this.kredits.syncContributors, this.kredits.syncContributors.perform); } - schedule('afterRender', this.kredits.syncContributions, - this.kredits.syncContributions.perform); + if (this.kredits.contributionsNeedSync) { + schedule('afterRender', this.kredits.syncContributions, + this.kredits.syncContributions.perform); + } }); } }); diff --git a/app/services/kredits.js b/app/services/kredits.js index c0b5117..559afd3 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -22,7 +22,6 @@ import Contribution from 'kredits-web/models/contribution' export default Service.extend({ browserCache: service(), - contributorsNeedFetch: false, currentBlock: null, currentUserAccounts: null, // default to not having an account. this is the wen web3 is loaded. @@ -35,6 +34,10 @@ export default Service.extend({ currentUserIsCore: alias('currentUser.isCore'), hasAccounts: notEmpty('currentUserAccounts'), + // When data was loaded from cache, we need to fetch updates from the network + contributorsNeedSync: false, + contributionsNeedSync: false, + contributionsUnconfirmed: computed('contributions.[]', 'currentBlock', function() { return this.contributions.filter(contribution => { return contribution.confirmedAt > this.currentBlock; @@ -180,7 +183,7 @@ export default Service.extend({ const numCachedContributors = await this.browserCache.contributors.length(); if (numCachedContributors > 0) { await this.loadContributorsFromCache(); - this.set('contributorsNeedFetch', true); + this.set('contributorsNeedSync', true); } else { await this.fetchContributors(); } @@ -188,6 +191,7 @@ export default Service.extend({ const numCachedContributions = await this.browserCache.contributions.length(); if (numCachedContributions > 0) { await this.loadContributionsFromCache(); + this.set('contributionsNeedSync', true); } else { await this.fetchContributions({ page: { size: 30 } }); } -- 2.50.1 From bac4c1c42561cc7271c10ecba5ded701efe25bcd Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 29 May 2020 22:04:03 +0200 Subject: [PATCH 08/10] Load all past contributions once everything else is loaded --- app/routes/application.js | 2 ++ app/services/kredits.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/routes/application.js b/app/routes/application.js index 3aec684..d97076f 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -32,6 +32,8 @@ export default Route.extend({ schedule('afterRender', this.kredits.syncContributions, this.kredits.syncContributions.perform); } + schedule('afterRender', this.kredits.fetchAllContributions, + this.kredits.fetchAllContributions.perform); }); } }); diff --git a/app/services/kredits.js b/app/services/kredits.js index 559afd3..5d829f6 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -8,7 +8,7 @@ import { alias, notEmpty } from '@ember/object/computed'; import { isEmpty, isPresent } from '@ember/utils'; import { inject as service } from '@ember/service'; -import { task } from 'ember-concurrency'; +import { task, taskGroup } from 'ember-concurrency'; import groupBy from 'kredits-web/utils/group-by'; import processContributorData from 'kredits-web/utils/process-contributor-data'; @@ -328,10 +328,12 @@ export default Service.extend({ }); }, + contributionTasks: taskGroup().enqueue(), + syncContributions: task(function * () { yield this.fetchNewContributions.perform(); yield this.syncUnconfirmedContributions.perform(); - }), + }).group('contributionTasks'), fetchNewContributions: task(function * () { const count = yield this.kredits.Contribution.functions.contributionsCount(); @@ -350,6 +352,32 @@ export default Service.extend({ } }), + fetchAllContributions: task(function * () { + const count = yield this.kredits.Contribution.functions.contributionsCount(); + const allIds = [...Array(count+1).keys()]; + allIds.shift(); // remove first item, which is 0 + const loadedContributions = new Set(this.contributions.mapBy('id')); + const toFetch = allIds.filter(id => !loadedContributions.has(id)); + if (toFetch.length === 0) { + console.debug(`[kredits] No contributions left to fetch`); + return; + } + console.debug(`[kredits] Fetching ${toFetch.length} past contributions`); + let countFetched = 0; + + for (let id = count; id > 0; id--) { + if (loadedContributions.has(id)) { + continue; + } else { + const data = yield this.kredits.Contribution.getById(id); + const c = this.loadContributionFromData(data); + yield this.browserCache.contributions.setItem(c.id.toString(), c.serialize()); + countFetched++; + } + } + console.debug(`[kredits] Cached ${countFetched} past contributions`); + }).group('contributionTasks'), + syncUnconfirmedContributions: task(function * () { if (this.contributionsUnconfirmed.length > 0) { console.debug(`[kredits] Syncing unconfirmed contributions`); -- 2.50.1 From 302c3315a3300fc9800bd7f75fa242e5e2a08ad4 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 29 May 2020 22:28:42 +0200 Subject: [PATCH 09/10] Update debug logs while fetching past contributions --- app/routes/application.js | 4 ++-- app/services/kredits.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/routes/application.js b/app/routes/application.js index d97076f..92f0e9d 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -32,8 +32,8 @@ export default Route.extend({ schedule('afterRender', this.kredits.syncContributions, this.kredits.syncContributions.perform); } - schedule('afterRender', this.kredits.fetchAllContributions, - this.kredits.fetchAllContributions.perform); + schedule('afterRender', this.kredits.fetchMissingContributions, + this.kredits.fetchMissingContributions.perform); }); } }); diff --git a/app/services/kredits.js b/app/services/kredits.js index 5d829f6..91d09e9 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -352,7 +352,7 @@ export default Service.extend({ } }), - fetchAllContributions: task(function * () { + fetchMissingContributions: task(function * () { const count = yield this.kredits.Contribution.functions.contributionsCount(); const allIds = [...Array(count+1).keys()]; allIds.shift(); // remove first item, which is 0 @@ -373,6 +373,9 @@ export default Service.extend({ const c = this.loadContributionFromData(data); yield this.browserCache.contributions.setItem(c.id.toString(), c.serialize()); countFetched++; + if (countFetched % 20 === 0) { + console.debug(`[kredits] Fetched ${countFetched} more contributions`); + } } } console.debug(`[kredits] Cached ${countFetched} past contributions`); -- 2.50.1 From c64a50354699a1ceb0cf535055cd506609c70139 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 31 May 2020 12:46:51 +0200 Subject: [PATCH 10/10] Remove unused async from function Throws a linter warning, now that it's not an RSVP promise anymore. --- app/services/kredits.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/kredits.js b/app/services/kredits.js index 91d09e9..e892f56 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -94,7 +94,7 @@ export default Service.extend({ getEthProvider () { let ethProvider; - return new Promise(async (resolve) => { + return new Promise(resolve => { function instantiateWithoutAccount () { console.debug('[kredits] Creating new instance from npm module class'); console.debug(`[kredits] providerURL: ${config.web3ProviderUrl}`); -- 2.50.1