feat(refresh): added refresh button on game detail view to refresh metadata

Resolves grimsi/gameyfin#45
This commit is contained in:
shawly
2022-10-19 23:35:24 +02:00
parent 6ee1117f3d
commit 130ec4565d
6 changed files with 45 additions and 3 deletions
+1
View File
@@ -7,4 +7,5 @@ export interface GamesApi {
getGame(slug: String): Observable<DetectedGameDto>;
getGameOverviews(): Observable<GameOverviewDto[]>;
getAllGameMappings(): Observable<Map<string, string>>;
refreshGame(slug: String): Observable<DetectedGameDto>;
}
@@ -33,6 +33,9 @@
<div fxLayout="column" fxFlex="40" fxLayoutGap="16px">
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="16px">
<button mat-raised-button color="secondary" (click)="refreshGame()" title="Refresh metadata">
<mat-icon>refresh</mat-icon>
</button>
<button mat-raised-button color="primary" (click)="downloadGame()">
<mat-icon>download</mat-icon>
</button>
@@ -48,6 +48,24 @@ export class GameDetailViewComponent {
this.gamesService.downloadGame(this.game.slug);
}
public refreshGame(): void {
this.gamesService.refreshGame(this.game.slug).subscribe({
next: game => {
this.game = game;
if(game.companies !== undefined) {
this.companiesWithLogo = game.companies.filter(c => c.logoId !== undefined && c.logoId.length > 0);
}
},
error: error => {
if (error.status === 404) {
this.router.navigate(['/library']);
} else {
console.error(error);
}
}
});
}
public bytesAsHumanReadableString(bytes: number): string {
const thresh = 1024;
@@ -92,6 +92,10 @@ export class GamesService implements GamesApi {
window.open(`v1${this.apiPath}/game/${slug}/download`, '_top');
}
refreshGame(slug: String): Observable<DetectedGameDto> {
return this.http.get<DetectedGameDto>(`${this.apiPath}/game/${slug}/refresh`);
}
getGameOverviews(): Observable<GameOverviewDto[]> {
return this.http.get<GameOverviewDto[]>(`${this.apiPath}/game-overviews`);
}