Cache contribution vetos

Fixes potentially not marking contributions as vetoed if there's no
incoming event after loading the app. Also improves performance either
way.
This commit is contained in:
Râu Cao
2022-11-11 20:29:54 +01:00
parent 11f19c8344
commit 92056517a6
+7 -6
View File
@@ -675,14 +675,15 @@ export default Service.extend({
await this.browserCache.contributions.setItem(c.id.toString(), c.serialize()); await this.browserCache.contributions.setItem(c.id.toString(), c.serialize());
}, },
handleContributionVetoed (contributionId) { async handleContributionVetoed (contributionId) {
console.debug('[kredits] ContributionVetoed event received for ', contributionId); console.debug('[kredits] ContributionVetoed event received for ', contributionId);
const contribution = this.contributions.findBy('id', contributionId); const c = this.contributions.findBy('id', contributionId);
console.debug('[kredits] contribution', contribution);
if (contribution) { if (c) {
contribution.set('vetoed', true); console.debug('[kredits] Updating contribution', c);
contribution.set('pendingTx', null); c.set('vetoed', true);
c.set('pendingTx', null);
await this.browserCache.contributions.setItem(c.id.toString(), c.serialize());
} }
}, },