Skip to content

Commit 41337cd

Browse files
committed
Added handling of manual Marvel Unlimited comic IDs, because the Marvel API is broken, and added Uncanny Avengers Vol 1
1 parent 2b0c5c8 commit 41337cd

34 files changed

Lines changed: 96 additions & 13 deletions

src/app/api-interactions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export class ApiInteractions {
3636
* @param seriesVolumeMarvelID the series ID in the Marvel API
3737
*/
3838
public setAPIComicData = (comic: Comic, seriesVolumeMarvelID: string) => {
39+
if (comic.marvelUnlimitedId) {
40+
comic.link = 'https://www.marvel.com/comics/issue/' + comic.marvelUnlimitedId + '/read';
41+
return;
42+
}
43+
3944
const params = new HttpParams()
4045
.set('issueNumber', comic.issue)
4146
.set('series', seriesVolumeMarvelID)

src/app/app.component.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,18 +387,21 @@ export class AppComponent implements OnInit {
387387
preserveFragment: true });
388388
this.router.navigateByUrl(urlTree);
389389

390-
// Get the series volume containing this comic
391-
const expandedSeriesVolume = find(this.seriesVolumes, ['id', currentComic.seriesVolumeId]);
392-
if (!expandedSeriesVolume) {
393-
return console.error('The expanded series volume could not be found', currentComic.seriesVolumeId);
394-
}
390+
let expandedSeriesVolume;
391+
// Get the series volume containing this comic, if we don't already have the Marvel Unlimited comic ID
392+
if (!currentComic.marvelUnlimitedId) {
393+
expandedSeriesVolume = find(this.seriesVolumes, ['id', currentComic.seriesVolumeId]);
394+
if (!expandedSeriesVolume) {
395+
return console.error('The expanded series volume could not be found', currentComic.seriesVolumeId);
396+
}
395397

396-
if (!expandedSeriesVolume.marvelId) {
397-
// We await this because setAPIComicData depends on having a marvel ID set
398-
expandedSeriesVolume.marvelId = await this.getMarvelSeriesVolumeId(expandedSeriesVolume);
398+
if (!expandedSeriesVolume.marvelId) {
399+
// We await this because setAPIComicData depends on having a marvel ID set
400+
expandedSeriesVolume.marvelId = await this.getMarvelSeriesVolumeId(expandedSeriesVolume);
401+
}
399402
}
400403

401-
this.apiInteractions.setAPIComicData(currentComic, expandedSeriesVolume.marvelId);
404+
this.apiInteractions.setAPIComicData(currentComic, expandedSeriesVolume?.marvelId);
402405
}
403406

404407
/*

src/app/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export interface Comic {
4242
image?: string;
4343
issue?: string;
4444
link?: string;
45+
marvelUnlimitedId?: number;
4546
monthPublished?: number;
4647
yearPublished?: number;
4748
series?: string;
200 KB
Loading
465 KB
Loading
106 KB
Loading
90.4 KB
Loading
61.1 KB
Loading
61.8 KB
Loading
275 KB
Loading

0 commit comments

Comments
 (0)