Advertisement
Guest User

Untitled

a guest
Jun 29th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. getReview(id?: number) {
  2.     this.previousReviewId = this.nextReviewId = 0;
  3.  
  4.     if (this.review.isCompleted) {
  5.       this.updateReview(this.review)
  6.         .then(() => {
  7.           this.reviewService.getReview(id).subscribe(review => {
  8.             if (this.fromReviewList && this.review.id != null) {
  9.               this.fromReviewList = false;
  10.             }
  11.             this.review = null;
  12.             this.review = this.mapReview(review);
  13.             this.previousReviewId = review.previousId;
  14.             this.nextReviewId = review.nextId;
  15.           });
  16.         });
  17.     }
  18.     else {
  19.       this.reviewService.getReview(id).subscribe(review => {
  20.         if (this.fromReviewList && this.review.id != null) {
  21.           this.fromReviewList = false;
  22.         }
  23.         this.review = null;
  24.         this.review = this.mapReview(review);
  25.         this.previousReviewId = review.previousId;
  26.         this.nextReviewId = review.nextId;
  27.       });
  28.     }
  29.   }
  30.  
  31.   updateReview(review: Review): Promise<void> {
  32.     return Promise<void>(resolve => {
  33.       if (this.review && this.review.id) {
  34.         this.reviewService.updateReview(this.review)
  35.           .takeUntil(this.componetDestroyed$)
  36.           .subscribe(() => {
  37.             resolve(null);
  38.           });
  39.       }
  40.     });
  41.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement