(render)
| 548 | } |
| 549 | |
| 550 | update (render) { |
| 551 | delete this.state |
| 552 | delete this.stateMessage |
| 553 | if (!__guard__(me.get('stripe'), x => x.recipients)) { return } |
| 554 | this.unsubscribingRecipients = [] |
| 555 | |
| 556 | const options = { cache: false, url: `/db/user/${me.id}/stripe` } |
| 557 | options.success = info => { |
| 558 | let card |
| 559 | this.sponsorSub = info.sponsorSubscription |
| 560 | if (card = info.card) { |
| 561 | this.card = `${card.brand}: x${card.last4}` |
| 562 | } |
| 563 | return render() |
| 564 | } |
| 565 | this.supermodel.addRequestResource('recipients_payment_info', options).load() |
| 566 | |
| 567 | const onSubRecipientsSuccess = recipientsMap => { |
| 568 | this.recipients = recipientsMap |
| 569 | let count = 0 |
| 570 | for (const userID in this.recipients) { |
| 571 | const recipient = this.recipients[userID] |
| 572 | if (!recipient.cancel_at_period_end) { count++ } |
| 573 | if ((this.recipientEmails != null) && (this.justSubscribed != null) && Array.from(this.recipientEmails).includes(recipient.emailLower)) { |
| 574 | this.justSubscribed.push(recipient.emailLower) |
| 575 | } |
| 576 | } |
| 577 | this.nextPaymentAmount = utils.getSponsoredSubsAmount(basicPlanPrice, count, (__guard__(me.get('stripe'), x1 => x1.subscriptionID) != null)) |
| 578 | this.recipientEmails = [] |
| 579 | return render() |
| 580 | } |
| 581 | return this.supermodel.addRequestResource('sub_recipients', { |
| 582 | url: '/db/user/-/sub_recipients', |
| 583 | method: 'POST', |
| 584 | success: onSubRecipientsSuccess |
| 585 | }, 0).load() |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | function __guard__ (value, transform) { |
no test coverage detected