Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 25, 2024
2 parents 18957d6 + ef2d08d commit 803fc3e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/app/core/services/issue.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class IssueService {
private issuesPollSubscription: Subscription;
/** Whether the IssueService is downloading the data from Github*/
public isLoading = new BehaviorSubject<boolean>(false);
/** Whether the IssueService is creating a new team response */
private isCreatingTeamResponse = false;

constructor(
private githubService: GithubService,
Expand Down Expand Up @@ -80,15 +82,19 @@ export class IssueService {
*/
pollIssue(issueId: number): Observable<Issue> {
return timer(0, IssueService.POLL_INTERVAL).pipe(
exhaustMap(() =>
this.githubService.fetchIssueGraphql(issueId).pipe(
map((response) => {
const issue = this.createIssueModel(response);
this.updateLocalStore(issue);
return issue;
}),
catchError((err) => this.getIssue(issueId))
)
exhaustMap(() => {
if (this.isCreatingTeamResponse) {
return EMPTY;
}
return this.githubService.fetchIssueGraphql(issueId).pipe(
map((response) => {
const issue = this.createIssueModel(response);
this.updateLocalStore(issue);
return issue;
}),
catchError((err) => this.getIssue(issueId))
);
}
)
);
}
Expand Down Expand Up @@ -193,11 +199,13 @@ export class IssueService {

createTeamResponse(issue: Issue): Observable<Issue> {
// The issue must be updated first to ensure that fields like assignees are valid
this.isCreatingTeamResponse = true;
const teamResponse = issue.createGithubTeamResponse();
return this.updateGithubIssue(issue).pipe(
mergeMap((response: GithubIssue) => {
return this.githubService.createIssueComment(issue.id, teamResponse).pipe(
map((githubComment: GithubComment) => {
this.isCreatingTeamResponse = false;
issue.githubComments = [githubComment, ...issue.githubComments.filter((c) => c.id !== githubComment.id)];
response.comments = issue.githubComments;
return this.createIssueModel(response);
Expand Down

0 comments on commit 803fc3e

Please sign in to comment.