-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(discover): 🐛 Created new Image component to handle 429's from TMDB (
- Loading branch information
Showing
14 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Ombi/ClientApp/src/app/components/image/image.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<img src="{{baseUrl + src}}" (onError)="onError($event)" [class]="class" [id]="id" [style]="style"/> |
57 changes: 57 additions & 0 deletions
57
src/Ombi/ClientApp/src/app/components/image/image.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { OmbiCommonModules } from "../modules"; | ||
import { ChangeDetectionStrategy, Component, ElementRef, Inject, Input, ViewEncapsulation } from "@angular/core"; | ||
import { RequestType } from "../../interfaces"; | ||
import { APP_BASE_HREF } from "@angular/common"; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'ombi-image', | ||
imports: [...OmbiCommonModules], | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './image.component.html', | ||
}) | ||
export class ImageComponent { | ||
|
||
@Input() public src: string; | ||
@Input() public type: RequestType; | ||
|
||
// Attributes from the parent | ||
@Input() public class: string; | ||
@Input() public id: string; | ||
@Input() public alt: string; | ||
@Input() public style: string; | ||
|
||
public baseUrl: string = ""; | ||
|
||
public defaultTv = "/images/default_tv_poster.png"; | ||
private defaultMovie = "/images/default_movie_poster.png"; | ||
private defaultMusic = "i/mages/default-music-placeholder.png"; | ||
|
||
constructor (@Inject(APP_BASE_HREF) public href: string) { | ||
if (this.href.length > 1) { | ||
this.baseUrl = this.href; | ||
} | ||
} | ||
|
||
public onError(event: any) { | ||
// set to a placeholder | ||
switch(this.type) { | ||
case RequestType.movie: | ||
event.target.src = this.baseUrl + this.defaultMovie; | ||
break; | ||
case RequestType.tvShow: | ||
event.target.src = this.baseUrl + this.defaultTv; | ||
break; | ||
case RequestType.album: | ||
event.target.src = this.baseUrl + this.defaultMusic; | ||
break; | ||
} | ||
|
||
// Retry the original image | ||
const timeout = setTimeout(() => { | ||
event.target.src = this.src; | ||
clearTimeout(timeout); | ||
}, Math.floor(Math.random() * (7000 - 1000 + 1)) + 1000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./image-background/image-background.component"; | ||
export * from "./image-background/image-background.component"; | ||
export * from "./image/image.component"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,7 @@ small { | |
} | ||
|
||
|
||
.image { | ||
::ng-deep .image { | ||
border-radius: 10px; | ||
opacity: 1; | ||
display: block; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...lientApp/src/app/media-details/components/shared/media-poster/media-poster.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters