Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<h1>🤨</h1>
<p>{{ error }}</p>
<footer>
<a class="button mediun border" [routerLink]="'/'">🏠</a>
<button autofocus class="button border large primary"
<a ch-button class=" mediun border" [routerLink]="'/'">🏠</a>
<button autofocus ch-button class=" border large primary"
(click)="onRefreshData()">{{lang.ph().tryAgain}}</button>
</footer>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, output, inject, input } from '@angular/core';
import { LangService } from '../../../../shared/data-access/lang.service';
import { BehaviorSubject, Observable, of } from 'rxjs';
import { CompositionEpisode } from '../../utils';
import { Playlist, PlaylistItem } from '../../../../playlist/data-access/playlist.service';
import { ChtnkEpisode } from '../../../../shared/models/chtnk-composition';

@Component({
selector: 'app-common-read',
Expand All @@ -15,7 +15,7 @@ export class CommonReadComponent {

error$ = input.required<BehaviorSubject<string | null>>();
loading$ = input.required<BehaviorSubject<boolean>>();
episode$ = input.required<Observable<CompositionEpisode | null>>();
episode$ = input.required<Observable<ChtnkEpisode | null>>();

playlist = input<Playlist>([]);
playlistLink = input("");
Expand Down
56 changes: 0 additions & 56 deletions src/app/@site-modules/@common-read/utils/composition.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/app/@site-modules/@common-read/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './composition';
export * from './read-base-component'
17 changes: 8 additions & 9 deletions src/app/@site-modules/@common-read/utils/read-base-component.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { BehaviorSubject, MonoTypeOperatorFunction, Observable, OperatorFunction, Subscription, catchError, combineLatest, finalize, of, tap } from "rxjs";
import { CompositionEpisode } from "./composition";
import { ActivatedRoute, ParamMap } from "@angular/router";
import { Title } from "@angular/platform-browser";
import { ChangeDetectorRef, OnDestroy, WritableSignal, inject, output, signal } from "@angular/core";
import { ChangeDetectorRef, WritableSignal, inject, signal } from "@angular/core";
import { LangService } from "../../../shared/data-access/lang.service";
import { HistoryService } from "../../../history/data-access/history.service";
import { PlaylistItem, PlaylistService, isPlaylist } from "../../../playlist/data-access/playlist.service";
import { MetaTagsService } from "../../../shared/data-access/meta-tags.service";
import { ViewerService } from "../../../viewer/services";
import { ChtnkEpisode } from "../../../shared/models/chtnk-composition";

export abstract class ReadBaseComponent {
protected refresh$: BehaviorSubject<null> = new BehaviorSubject<null>(null);
error$: BehaviorSubject<string | null> = new BehaviorSubject<string | null>(null);
loading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
episode$: Observable<CompositionEpisode | null> = of(null);
episode$: Observable<ChtnkEpisode | null> = of(null);

plObserv: Subscription | undefined;
playlistLink = signal('')
Expand All @@ -23,7 +22,7 @@ export abstract class ReadBaseComponent {
this.route.pathFromRoot[0].queryParams.subscribe(q => {
const vm = q['vm'] // view mode param

if(vm && vm !== this.viewerService.viewModeOption().code)
if (vm && vm !== this.viewerService.viewModeOption().code)
this.viewerService.setViewModeOptionByCode(vm)

const pl = q['list'] // playlist
Expand Down Expand Up @@ -113,8 +112,8 @@ export abstract class ReadBaseComponent {
}
site = '';
post_id = '';
protected tapSaveToHistory(site: string, post_id: string): MonoTypeOperatorFunction<CompositionEpisode> {
return tap(async (episode: CompositionEpisode) => {
protected tapSaveToHistory(site: string, post_id: string): MonoTypeOperatorFunction<ChtnkEpisode> {
return tap(async (episode: ChtnkEpisode) => {
if (episode) {
this.site = site;
this.post_id = post_id;
Expand All @@ -135,8 +134,8 @@ export abstract class ReadBaseComponent {
cdr = inject(ChangeDetectorRef)


protected tapSaveToCurrentPlaylistItem(site: string, post_id: string): MonoTypeOperatorFunction<CompositionEpisode> {
return tap(async (episode: CompositionEpisode) => {
protected tapSaveToCurrentPlaylistItem(site: string, post_id: string): MonoTypeOperatorFunction<ChtnkEpisode> {
return tap(async (episode: ChtnkEpisode) => {

if (episode) {

Expand Down
6 changes: 3 additions & 3 deletions src/app/@site-modules/comick/comick.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { HttpClient } from '@angular/common/http';
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Observable, map } from 'rxjs';
import { environment } from '../../../environments/environment';
import { CompositionEpisode } from '../@common-read';
import { ProxyService } from '../../shared/data-access/proxy.service';
import { isPlatformServer } from '@angular/common';
import { ChtnkEpisode } from '../../shared/models/chtnk-composition';

@Injectable({
providedIn: 'root'
Expand All @@ -14,7 +14,7 @@ export class ComickService {
http: HttpClient = inject(HttpClient)
proxy: ProxyService = inject(ProxyService)

getComposition(id: string): Observable<CompositionEpisode> {
getComposition(id: string): Observable<ChtnkEpisode> {
const url = isPlatformServer(this.platformId)
? environment.comickHost + id
: this.proxy.proxyUrl(environment.comickHost + id);
Expand All @@ -23,7 +23,7 @@ export class ComickService {
.pipe(map((data) => { return this.map(data) }))
}

map(data: any): CompositionEpisode {
map(data: any): ChtnkEpisode {
const nsfw = data.matureContent;
const mappedResponse = {
title: data.chapTitle,
Expand Down
11 changes: 6 additions & 5 deletions src/app/@site-modules/imgchest/imgchest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
import { environment } from '../../../environments/environment';
import { Observable, map } from 'rxjs';
import { CompositionEpisode, CompositionImage } from '../@common-read';
import { ProxyService } from '../../shared/data-access/proxy.service';
import { isPlatformServer } from '@angular/common';
import { ChtnkEpisode, ChtnkImage } from '../../shared/models/chtnk-composition';

interface ImgchestRespCompImage {
id: string;
description: string;
Expand Down Expand Up @@ -40,7 +41,7 @@ export class ImgchestService {

constructor() { }

getComposition(id: string): Observable<CompositionEpisode> {
getComposition(id: string): Observable<ChtnkEpisode> {
const headers = new HttpHeaders({
'Authorization': `Bearer ${this.clientId}`
});
Expand All @@ -54,12 +55,12 @@ export class ImgchestService {
}


map(data: ImgchestRespComp): CompositionEpisode {
const res: CompositionEpisode = {
map(data: ImgchestRespComp): ChtnkEpisode {
const res: ChtnkEpisode = {
title: data.title,
episode: 0,
nsfw: (data.nsfw) as unknown as boolean,
images: data.images.map((i): CompositionImage => {
images: data.images.map((i): ChtnkImage => {
return {
src: this.proxy.proxyUrl(i.link),
alt: i.description,
Expand Down
12 changes: 7 additions & 5 deletions src/app/@site-modules/imgur/imgur.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
import { Observable, map } from 'rxjs';
import { CompositionEpisode, CompositionImage } from '../@common-read';
import { ChtnkEpisode, ChtnkImage } from '../../shared/models/chtnk-composition';


interface ImgurRespCompImage {
link: string;
width: number;
Expand Down Expand Up @@ -32,7 +34,7 @@ export class ImgurService {

constructor(private http: HttpClient) { }

getComposition(id: string): Observable<CompositionEpisode> {
getComposition(id: string): Observable<ChtnkEpisode> {
const headers = new HttpHeaders({
'Authorization': `Client-ID ${this.clientId}`
});
Expand All @@ -42,14 +44,14 @@ export class ImgurService {
}


map(data: ImgurRespComp): CompositionEpisode {
const res: CompositionEpisode = {
map(data: ImgurRespComp): ChtnkEpisode {
const res: ChtnkEpisode = {
title: data.title,
episode: 0,
nsfw: (data.nsfw) as unknown as boolean,
images: data.images
.filter(i => i.type.startsWith('image/'))
.map((i): CompositionImage => {
.map((i): ChtnkImage => {
return {
src: i.link,
width: i.width,
Expand Down
10 changes: 5 additions & 5 deletions src/app/@site-modules/mangadex/mangadex.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { HttpClient } from '@angular/common/http';
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
import { environment } from '../../../environments/environment';
import { Observable, catchError, map, throwError } from 'rxjs';
import { CompositionEpisode, CompositionImage, CompositionPublisher } from '../@common-read';
import { ProxyService } from '../../shared/data-access/proxy.service';
import { isPlatformServer } from '@angular/common';
import { ChtnkEpisode, ChtnkImage, ChtnkPublisher } from '../../shared/models/chtnk-composition';

interface MdChapterImages {
hash: string;
Expand Down Expand Up @@ -94,7 +94,7 @@ export class MangadexService {
http: HttpClient = inject(HttpClient)
proxy: ProxyService = inject(ProxyService)

getChapterImages(id: string): Observable<CompositionImage[]> {
getChapterImages(id: string): Observable<ChtnkImage[]> {
const url = isPlatformServer(this.platformId)
? environment.mangadexHost + id
: this.proxy.proxyUrl(environment.mangadexHost + id);
Expand All @@ -111,7 +111,7 @@ export class MangadexService {
)
}

getChapter(id: string): Observable<CompositionEpisode> {
getChapter(id: string): Observable<ChtnkEpisode> {
const url = isPlatformServer(this.platformId)
? environment.mangadexChapter + id
: this.proxy.proxyUrl(environment.mangadexChapter + id);
Expand All @@ -132,7 +132,7 @@ export class MangadexService {
volume: data.data.attributes.volume,
chapter: data.data.attributes.chapter,
images: []
} as unknown as CompositionEpisode
} as unknown as ChtnkEpisode
}),
catchError(error => throwError(() => error))
)
Expand All @@ -156,7 +156,7 @@ export class MangadexService {
})
}

getScanlationGroup(id: string): Observable<CompositionPublisher | undefined> {
getScanlationGroup(id: string): Observable<ChtnkPublisher | undefined> {
const endpoint = environment.mangadexScanlationGroup + id;
const url = isPlatformServer(this.platformId) ? endpoint : this.proxy.proxyUrl(endpoint);

Expand Down
6 changes: 3 additions & 3 deletions src/app/@site-modules/nhentai/nhentai.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { HttpClient } from '@angular/common/http';
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Observable, map } from 'rxjs';
import { environment } from '../../../environments/environment';
import { CompositionEpisode } from '../@common-read';
import { ProxyService } from '../../shared/data-access/proxy.service';
import { isPlatformServer } from '@angular/common';
import { ChtnkEpisode } from '../../shared/models/chtnk-composition';

@Injectable({
providedIn: 'root'
Expand All @@ -14,7 +14,7 @@ export class NhentaiService {
http: HttpClient = inject(HttpClient)
proxy: ProxyService = inject(ProxyService)

getComposition(id: string): Observable<CompositionEpisode> {
getComposition(id: string): Observable<ChtnkEpisode> {
const url = isPlatformServer(this.platformId)
? environment.nhentaiHost + id
: this.proxy.proxyUrl(environment.nhentaiHost + id);
Expand All @@ -23,7 +23,7 @@ export class NhentaiService {
.pipe(map((data) => { return this.map(data) }))
}

map(data: any): CompositionEpisode {
map(data: any): ChtnkEpisode {
const mediaId = data.media_id;
const mappedResponse = {
title: data.title.pretty,
Expand Down
8 changes: 4 additions & 4 deletions src/app/@site-modules/pixiv/pixiv.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { HttpClient } from '@angular/common/http';
import { inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Observable, map } from 'rxjs';
import { environment } from '../../../environments/environment';
import { CompositionEpisode, CompositionPublisher } from '../@common-read';
import { ProxyService } from '../../shared/data-access/proxy.service';
import { isPlatformServer } from '@angular/common';
import { ChtnkEpisode, ChtnkPublisher } from '../../shared/models/chtnk-composition';

@Injectable({
providedIn: 'root'
Expand All @@ -14,7 +14,7 @@ export class PixivService {
http: HttpClient = inject(HttpClient)
proxy: ProxyService = inject(ProxyService)

getComposition(id: string): Observable<CompositionEpisode> {
getComposition(id: string): Observable<ChtnkEpisode> {
const url = isPlatformServer(this.platformId)
? environment.pixivHost + id
: this.proxy.proxyUrl(environment.pixivHost + id);
Expand All @@ -23,7 +23,7 @@ export class PixivService {
.pipe(map((data) => { return this.map(data.body) }))
}

map(data: any): CompositionEpisode {
map(data: any): ChtnkEpisode {

const mappedResponse = {
title: data.illust_details.title,
Expand All @@ -35,7 +35,7 @@ export class PixivService {
avatar: this.proxy.proxyUrl(data.author_details.profile_img.main) + '&ref=https://www.pixiv.net' as string,
description: '',
links: []
} as unknown as CompositionPublisher,
} as unknown as ChtnkPublisher,

images: (data.illust_details.manga_a ? data.illust_details.manga_a.map((item: any, index: number) => {
return {
Expand Down
8 changes: 4 additions & 4 deletions src/app/@site-modules/read/read.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, catchError, tap, throwError } from 'rxjs';
import { CompositionEpisode, isCompositionEpisode } from '../@common-read';
import { ChtnkEpisode, isChtnkEpisode } from '../../shared/models/chtnk-composition';

@Injectable({
providedIn: 'root'
Expand All @@ -10,10 +10,10 @@ export class ReadService {

constructor(private http: HttpClient) { }

getComposition(url: string): Observable<CompositionEpisode> {
return this.http.get<CompositionEpisode>(url)
getComposition(url: string): Observable<ChtnkEpisode> {
return this.http.get<ChtnkEpisode>(url)
.pipe(
tap(data => { if (!isCompositionEpisode(data)) throw new Error() }),
tap(data => { if (!isChtnkEpisode(data)) throw new Error() }),
catchError(error => throwError(() => error))
);
}
Expand Down
Loading
Loading