<commit_before>import { Component, EventEmitter, Input, Output } from '@angular/core';

import { Client } from '../../../services/api';
import { WalletService } from '../../../services/wallet';
import { Storage } from '../../../services/storage';
import { SessionFactory } from '../../../services/session';

@Component({
  moduleId: module.id,
  selector: 'minds-paywall',
  templateUrl: 'paywall.component.html'
})

export class PayWall {

  minds = (<any>window).Minds;

  inProgress : boolean = false;
  error : string;
  showCheckout : boolean = false;
  amount : number;
  nonce : string = "";
  showSignupModal: boolean = false;
  session = SessionFactory.build();

  @Output('entityChange') update : EventEmitter<any> = new EventEmitter;

  @Input() entity;

	constructor(public client: Client){
	}

  ngOnInit(){
    //get the subscription amount
  }

  checkout() {
    if (!this.session.isLoggedIn()) {
      this.showSignupModal = true;
      return;
    }

    this.inProgress = true;

    this.client.get('api/v1/payments/plans/exclusive/' + this.entity.guid)
      .then((response: any) => {
        this.inProgress = false;
        if(response.subscribed){
          this.update.next(response.entity);
          return;
        }
        this.showCheckout = true;
        this.amount = response.amount;
      })
      .catch(e => {
        this.inProgress = false;
        this.error = "Sorry, there was an error.";
      });
  }

  subscribe(nonce){
    this.showCheckout = false;
    this.inProgress = true;
    console.log('nonce: ' + nonce);
    this.client.post('api/v1/payments/plans/subscribe/' + this.entity.owner_guid + '/exclusive', {
        nonce: nonce
      })
      .then((response) => setTimeout(() => this.checkout(), 0))
      .catch(e => {
        this.inProgress = false;
        this.error = "Sorry, we couldn't complete the transaction."; 
      });
  }

  ngOnDestroy(){
  }

}<commit_msg>(fix): Add ChangeDetection to paywalled reminds<commit_after>import { Component, EventEmitter, Input, Output, ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';

import { Client } from '../../../services/api';
import { WalletService } from '../../../services/wallet';
import { Storage } from '../../../services/storage';
import { SessionFactory } from '../../../services/session';

@Component({
  moduleId: module.id,
  selector: 'minds-paywall',
  templateUrl: 'paywall.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})

export class PayWall {

  minds = (<any>window).Minds;

  inProgress : boolean = false;
  error : string;
  showCheckout : boolean = false;
  amount : number;
  nonce : string = "";
  showSignupModal: boolean = false;
  session = SessionFactory.build();

  @Output('entityChange') update : EventEmitter<any> = new EventEmitter;

  @Input() entity;

	constructor(public client: Client, public cd: ChangeDetectorRef){
	}

  ngOnInit(){
    //get the subscription amount
  }

  checkout() {
    if (!this.session.isLoggedIn()) {
      this.showSignupModal = true;
      this.detectChanges();
      return;
    }

    this.inProgress = true;
    this.detectChanges();

    this.client.get('api/v1/payments/plans/exclusive/' + this.entity.guid)
      .then((response: any) => {
        this.inProgress = false;
        if(response.subscribed){
          this.update.next(response.entity);
          this.detectChanges();
          return;
        }
        this.showCheckout = true;
        this.amount = response.amount;
        this.detectChanges();
      })
      .catch(e => {
        this.inProgress = false;
        this.error = "Sorry, there was an error.";
        this.detectChanges();
      });
  }

  subscribe(nonce){
    this.showCheckout = false;
    this.inProgress = true;
    this.detectChanges();
    console.log('nonce: ' + nonce);
    this.client.post('api/v1/payments/plans/subscribe/' + this.entity.owner_guid + '/exclusive', {
        nonce: nonce
      })
      .then((response) => setTimeout(() => this.checkout(), 0))
      .catch(e => {
        this.inProgress = false;
        this.error = "Sorry, we couldn't complete the transaction."; 
        this.detectChanges();
      });
  }

  ngOnDestroy(){
  }

  private detectChanges() {
    this.cd.markForCheck();
    this.cd.detectChanges();
  }

}
{'fraction_non_alphanumeric': 0.1572224802601022, 'fraction_numerical': 0.0013934045517882026, 'mean_word_length': 2.659303313508921, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '413749', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1315, 'n_words': 271}