fix(book-card): prefer audiobook covers for square mixed-format cards (#467)
This commit is contained in:
+31
@@ -299,6 +299,37 @@ describe('BookCardComponent', () => {
|
|||||||
expect(component.titleTooltip()).toContain('Volume One');
|
expect(component.titleTooltip()).toContain('Volume One');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('prefers the audiobook thumbnail for square covers when the book has an audiobook format', () => {
|
||||||
|
ref.setInput('book', makeBook({
|
||||||
|
id: 9,
|
||||||
|
primaryFile: {
|
||||||
|
id: 91,
|
||||||
|
bookId: 9,
|
||||||
|
bookType: 'EPUB',
|
||||||
|
extension: 'epub',
|
||||||
|
filePath: 'books/volume-nine.epub',
|
||||||
|
},
|
||||||
|
alternativeFormats: [
|
||||||
|
{
|
||||||
|
id: 92,
|
||||||
|
bookId: 9,
|
||||||
|
bookType: 'AUDIOBOOK',
|
||||||
|
extension: 'm4b',
|
||||||
|
filePath: 'books/volume-nine.m4b',
|
||||||
|
} as AdditionalFile,
|
||||||
|
],
|
||||||
|
}));
|
||||||
|
ref.setInput('useSquareCovers', true);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.coverImageUrl()).toBe('audio-thumb:9:2024-01-02');
|
||||||
|
|
||||||
|
ref.setInput('useSquareCovers', false);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component.coverImageUrl()).toBe('thumb:9:2024-01-01');
|
||||||
|
});
|
||||||
|
|
||||||
it('uses forced ebook mode for audiobook reads and falls back to the normal read flow otherwise', () => {
|
it('uses forced ebook mode for audiobook reads and falls back to the normal read flow otherwise', () => {
|
||||||
const audiobookWithAlternativeFormat = makeBook({
|
const audiobookWithAlternativeFormat = makeBook({
|
||||||
id: 12,
|
id: 12,
|
||||||
|
|||||||
+7
-1
@@ -111,8 +111,14 @@ export class BookCardComponent {
|
|||||||
this.book().primaryFile?.bookType === 'AUDIOBOOK' && !this.forceEbookMode()
|
this.book().primaryFile?.bookType === 'AUDIOBOOK' && !this.forceEbookMode()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
readonly hasAudiobookFormat = computed(() => {
|
||||||
|
const primaryFile = this.book().primaryFile;
|
||||||
|
const alternativeFormats = this.book().alternativeFormats ?? [];
|
||||||
|
return primaryFile?.bookType === 'AUDIOBOOK' || alternativeFormats.some(file => file.bookType === 'AUDIOBOOK');
|
||||||
|
});
|
||||||
|
|
||||||
readonly coverImageUrl = computed(() =>
|
readonly coverImageUrl = computed(() =>
|
||||||
this.isAudiobook()
|
(this.isAudiobook() || (this.useSquareCovers() && this.hasAudiobookFormat()))
|
||||||
? this.urlHelper.getAudiobookThumbnailUrl(this.book().id, this.book().metadata?.audiobookCoverUpdatedOn)
|
? this.urlHelper.getAudiobookThumbnailUrl(this.book().id, this.book().metadata?.audiobookCoverUpdatedOn)
|
||||||
: this.urlHelper.getThumbnailUrl(this.book().id, this.book().metadata?.coverUpdatedOn)
|
: this.urlHelper.getThumbnailUrl(this.book().id, this.book().metadata?.coverUpdatedOn)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user