Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #90 from ZimGil/#87-get-available-projects-after-l…
Browse files Browse the repository at this point in the history
…eaving

Get available project when leaving project
  • Loading branch information
ZimGil committed Nov 23, 2018
2 parents 71ae4fa + b3936bc commit 1219c07
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';

import { interval, timer, empty } from 'rxjs';
import { exhaustMap, mergeMap } from 'rxjs/operators';
import { exhaustMap, mergeMap, catchError } from 'rxjs/operators';

import { CommandService } from './services/command/command.service';
import { CommandRequest } from './models/angular-command-request';
Expand Down Expand Up @@ -127,15 +127,22 @@ export class AppComponent implements OnInit {
}

leaveProject(): void {
this.commandService.leaveProject()
.subscribe(
res => this.isAngularProject = false,
() => {
this.errorService.addError({
errorText: 'Unable to leave this project',
errorDescription: 'To run ngWiz on another project or to create a new one, please run it in the apropriate project direcroty'
});
this.commandService.leaveProject().pipe(
catchError(() => {
this.errorService.addError({
errorText: 'Unable to leave this project',
errorDescription: 'To run ngWiz on another project or to create a new one, please run it in the apropriate project direcroty'
});
return empty();
}),
mergeMap(res => {
this.isAngularProject = false;
return this.commandService.getProjects();
})
)
.subscribe((projects: string[]) => {
this.availableProjects = projects;
});
}

checkIfRunningServeCommand(): void {
Expand Down

0 comments on commit 1219c07

Please sign in to comment.