feat: almost abstractions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { Injectable } from "@angular/core";
|
||||
import { BehaviorSubject, Observable, map } from "rxjs";
|
||||
import { Parser } from "./parsers/parser";
|
||||
import { MangalibParserService } from "./parsers/rulib/mangalib.parser.service";
|
||||
import { IRulibChapterResult } from "./parsers/rulib/rulib.chapter.dto";
|
||||
import { IRulibChaptersResult } from "./parsers/rulib/rulib.chapters.dto";
|
||||
@@ -11,15 +12,20 @@ import { Datum, IRulibSearchResult } from "./parsers/rulib/rulib.search.dto";
|
||||
export class SearchService {
|
||||
private itemsTerm = new BehaviorSubject<Datum[]>([]);
|
||||
currentItemsTerm = this.itemsTerm.asObservable();
|
||||
private parser!: Parser;
|
||||
constructor(
|
||||
private parser: MangalibParserService,
|
||||
private http: HttpClient,
|
||||
private mangalibParser: MangalibParserService,
|
||||
) {}
|
||||
|
||||
setMangalibParser() {
|
||||
this.parser = this.mangalibParser;
|
||||
}
|
||||
|
||||
search(query: string): Observable<IRulibSearchResult> {
|
||||
return this.parser.searchManga(query).pipe(
|
||||
map((data) => {
|
||||
return data;
|
||||
return data as IRulibSearchResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -27,7 +33,7 @@ export class SearchService {
|
||||
getDetails(slug_url: string): Observable<IRulibDetailResult> {
|
||||
return this.parser.getDetails(slug_url).pipe(
|
||||
map((data) => {
|
||||
return data;
|
||||
return data as IRulibDetailResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -35,7 +41,7 @@ export class SearchService {
|
||||
getChapters(url: string): Observable<IRulibChaptersResult> {
|
||||
return this.parser.getChapters(url).pipe(
|
||||
map((data) => {
|
||||
return data;
|
||||
return data as IRulibChaptersResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -43,13 +49,14 @@ export class SearchService {
|
||||
getChapter(url: string, chapter: string, volume: string): Observable<IRulibChapterResult> {
|
||||
return this.parser.getChapter(url, chapter, volume).pipe(
|
||||
map((data) => {
|
||||
return data;
|
||||
return data as IRulibChapterResult;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
getImageServer() {
|
||||
return this.parser.imageServer;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).imageServer;
|
||||
}
|
||||
|
||||
getImageData(imageUrl: string): Observable<Uint8Array> {
|
||||
@@ -61,6 +68,7 @@ export class SearchService {
|
||||
}
|
||||
|
||||
isManhwa(url: string): Observable<boolean> {
|
||||
return this.parser.isManhwa(url);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (this.parser as any).isManhwa(url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user