@nina-protocol/nina-db 0.0.60 → 0.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,9 +106,12 @@ export default class Release extends Model {
106
106
  if (recipient.recipientAuthority.toBase58() !== "11111111111111111111111111111111") {
107
107
  const recipientAccount = await Account.findOrCreate(recipient.recipientAuthority.toBase58());
108
108
  const revenueShares = (await recipientAccount.$relatedQuery('revenueShares')).map(revenueShare => revenueShare.id);
109
- if (!revenueShares.includes(releaseRecord.id)) {
109
+ if (!revenueShares.includes(releaseRecord.id) && recipient.percentShares > 0) {
110
110
  await Account.relatedQuery('revenueShares').for(recipientAccount.id).relate(releaseRecord.id);
111
111
  }
112
+ else if (revenueShares.includes(releaseRecord.id) && recipient.percentShares === 0) {
113
+ await Account.relatedQuery('revenueShares').for(recipientAccount.id).unrelate().where('id', releaseRecord.id);
114
+ }
112
115
  }
113
116
  }
114
117
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -118,8 +118,10 @@ export default class Release extends Model {
118
118
  if (recipient.recipientAuthority.toBase58() !== "11111111111111111111111111111111") {
119
119
  const recipientAccount = await Account.findOrCreate(recipient.recipientAuthority.toBase58());
120
120
  const revenueShares = (await recipientAccount.$relatedQuery('revenueShares')).map(revenueShare => revenueShare.id);
121
- if (!revenueShares.includes(releaseRecord.id)) {
121
+ if (!revenueShares.includes(releaseRecord.id) && recipient.percentShares > 0) {
122
122
  await Account.relatedQuery('revenueShares').for(recipientAccount.id).relate(releaseRecord.id);
123
+ } else if (revenueShares.includes(releaseRecord.id) && recipient.percentShares === 0) {
124
+ await Account.relatedQuery('revenueShares').for(recipientAccount.id).unrelate().where('id', releaseRecord.id);
123
125
  }
124
126
  }
125
127
  } catch (error) {