change behavior of book card component to also show actual hyperlinks on the read button (#3192)
This commit is contained in:
@@ -4,7 +4,7 @@ import {AuthService} from './auth.service';
|
||||
import {BookService} from '../../features/book/service/book.service';
|
||||
import {CoverGeneratorComponent} from '../components/cover-generator/cover-generator.component';
|
||||
import {Router} from '@angular/router';
|
||||
import {Book} from '../../features/book/model/book.model';
|
||||
import {Book,BookType} from '../../features/book/model/book.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -119,6 +119,41 @@ export class UrlHelperService {
|
||||
});
|
||||
}
|
||||
|
||||
getBookPrimaryReadingUrl(book: Book) {
|
||||
const bookType: BookType | undefined = book.primaryFile?.bookType;
|
||||
|
||||
let baseUrl: string | null = null;
|
||||
|
||||
switch (bookType) {
|
||||
case 'PDF':
|
||||
baseUrl = 'pdf-reader';
|
||||
break;
|
||||
|
||||
case 'EPUB':
|
||||
case 'FB2':
|
||||
case 'MOBI':
|
||||
case 'AZW3':
|
||||
baseUrl = 'ebook-reader';
|
||||
break;
|
||||
|
||||
case 'CBX':
|
||||
baseUrl = 'cbx-reader';
|
||||
break;
|
||||
|
||||
case 'AUDIOBOOK':
|
||||
baseUrl = 'audiobook-player';
|
||||
break;
|
||||
}
|
||||
|
||||
if (!baseUrl) {
|
||||
console.error('Unsupported book type:', bookType);
|
||||
//Go to book URL as a fall-back
|
||||
return this.getBookUrl(book);
|
||||
}
|
||||
|
||||
return this.router.createUrlTree([`/${baseUrl}/book/${book.id}`], undefined);
|
||||
}
|
||||
|
||||
filterBooksBy(filterKey: string, filterValue: string) {
|
||||
if (filterKey === 'series') {
|
||||
return this.router.createUrlTree(['/series', encodeURIComponent(filterValue)])
|
||||
|
||||
Reference in New Issue
Block a user