Skip to content

Commit

Permalink
fix(pmp-web): fix error while trying get properties of null
Browse files Browse the repository at this point in the history
object
  • Loading branch information
Arkadiusz Pałka authored and MaciejSikorski committed Jan 27, 2020
1 parent fcd730e commit a73de94
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="repository-statistics__container">
<pmp-header-container
[avatarLabel]="repository.fullName"
[avatarLabel]="repository.name"
[avatarUrl]="repository.repositoryPictureUrl"
label="Pull requests pending"
></pmp-header-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,36 @@ import { untilDestroyed } from 'ngx-take-until-destroy';
import { RepositoryModel } from '@pimp-my-pr/shared/domain';
import { first } from 'rxjs/operators';

const mockedData = {
// TODO mocked data for repository
owner: 'valueadd',
fullName: 'pimp-my-pr',
name: 'pmp',
repositoryPictureUrl: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
prsStatistics: [
{
author: 'asda',
authorAvatarUrl: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
commentsCount: 123,
createdAt: '12/12/12',
linesOfCodeToCheck: 3245,
reviewCommentsCount: 234,
id: 2345,
timeWaiting: '124',
title: '12414',
url: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png'
}
]
};

@Component({
selector: 'pimp-my-pr-repository-statistics',
templateUrl: './repository-statistics.component.html',
styleUrls: ['./repository-statistics.component.scss']
})
export class RepositoryStatisticsComponent implements OnDestroy, OnInit {
repositoryName: string | null;
repository: RepositoryModel = {
// TODO mocked data for repository
owner: 'valueadd',
fullName: 'pimp-my-pr',
name: 'pmp',
repositoryPictureUrl: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
prsStatistics: [
{
author: 'asda',
authorAvatarUrl: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png',
commentsCount: 123,
createdAt: '12/12/12',
linesOfCodeToCheck: 3245,
reviewCommentsCount: 234,
id: 2345,
timeWaiting: '124',
title: '12414',
url: 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png'
}
]
};
repository: RepositoryModel;

constructor(
private cdr: ChangeDetectorRef,
Expand All @@ -43,14 +45,13 @@ export class RepositoryStatisticsComponent implements OnDestroy, OnInit {
ngOnDestroy(): void {}

ngOnInit(): void {
console.log('elo');
this.initGetRepositoryStatistics();
this.initSubscribeRepositoryStatistics();
}

private initSubscribeRepositoryStatistics(): void {
this.facade.repositoryStatistics$.pipe(untilDestroyed(this)).subscribe(repository => {
this.repository = repository;
this.repository = mockedData; /* TODO repository instead mockedData */
this.cdr.markForCheck();
});
}
Expand Down

0 comments on commit a73de94

Please sign in to comment.