message: refactor promise chains
diff: @@ -120,19 +120,18 @@ export class CourseManageContentComponent implements OnInit, OnDestroy {
  .subscribe(res => {
  if (res) {
  this.showProgress.toggleLoadingGlobal(true);
  - this.unitService.deleteItem(unit).then(
  - () => {
  - this.showProgress.toggleLoadingGlobal(false);
  + this.unitService.deleteItem(unit)
  + .then(() => {
  this.snackBar.open('Unit deleted.', '', {duration: 3000});
  - this.unitEditMode = false;
  - this.unitEditElement = null;
  + this.closeEditUnit();
  this.reloadCourse();
  - },
  - (error) => {
  - this.showProgress.toggleLoadingGlobal(false);
  + })
  + .catch((error) => {
  this.snackBar.open(error, '', {duration: 3000});
  - }
  - );
  + })
  + .then(() => {
  + this.showProgress.toggleLoadingGlobal(false);
  + });
  }
  });
  }
  @@ -143,29 +142,33 @@ export class CourseManageContentComponent implements OnInit, OnDestroy {
  .subscribe(res => {
  if (res) {
  this.showProgress.toggleLoadingGlobal(true);
  - this.lectureService.deleteItem(lecture).then(
  - (val) => {
  - this.showProgress.toggleLoadingGlobal(false);
  + this.lectureService.deleteItem(lecture)
  + .then((val) => {
  this.snackBar.open('Lecture deleted.', '', {duration: 3000});
  - this.lectureEditMode = false;
  - this.openedLecture = null;
  + this.closeEditUnit();
  + this.closeEditLecture();
  this.reloadCourse();
  - },
  - (error) => {
  - this.showProgress.toggleLoadingGlobal(false);
  + })
  + .catch((error) => {
  this.snackBar.open(error, '', {duration: 3000});
  - }
  - );
  + })
  + .then(() => {
  + this.showProgress.toggleLoadingGlobal(false);
  + });
  }
  });
  }
  reloadCourse() {
  - this.courseService.readSingleItem(this.course._id).then(
  - (val: any) => {
  + this.courseService.readSingleItem(this.course._id)
  + .then((val: any) => {
  this.course = val;
  - }, (error) => {
  + })
  + .catch((error) => {
  console.log(error);
  + })
  + .then(() => {
  + this.showProgress.toggleLoadingGlobal(false)
  });
  }
  