Queue image requests per source

If http protocol is h2 or newer, allow:
 - 5 requests per source
 - unlimited local source requests
This commit is contained in:
schroda
2025-11-22 23:49:01 +01:00
parent 890b304b4a
commit fe4bfd922e
9 changed files with 174 additions and 29 deletions

View File

@@ -39,6 +39,7 @@ export const ChapterHistoryCard = memo(({ chapter }: { chapter: ChapterHistoryLi
<Box sx={{ display: 'flex', flexGrow: 1, gap: 1 }}>
<ChapterCardThumbnail
mangaId={manga.id}
sourceId={manga.sourceId}
mangaTitle={manga.title}
thumbnailUrl={manga.thumbnailUrl}
thumbnailUrlLastFetched={manga.thumbnailUrlLastFetched}

View File

@@ -36,7 +36,7 @@ export type MangaChapterCountInfo = { chapters: Pick<MangaTypeGql['chapters'], '
export type MangaInLibraryInfo = Pick<MangaTypeGql, 'inLibrary'>;
export type MangaDownloadInfo = Pick<MangaTypeGql, 'downloadCount'> & MangaChapterCountInfo;
export type MangaUnreadInfo = Pick<MangaTypeGql, 'unreadCount'> & MangaChapterCountInfo;
export type MangaThumbnailInfo = Pick<MangaTypeGql, 'thumbnailUrl' | 'thumbnailUrlLastFetched'>;
export type MangaThumbnailInfo = Pick<MangaTypeGql, 'thumbnailUrl' | 'thumbnailUrlLastFetched' | 'sourceId'>;
export type MangaTrackRecordInfo = MangaIdInfo & {
trackRecords: { nodes: Pick<TrackRecordType, 'id' | 'trackerId'>[] };
};

View File

@@ -51,6 +51,7 @@ import {
import { getErrorMessage } from '@/lib/HelperFunctions.ts';
import { assertIsDefined } from '@/base/Asserts.ts';
import { Confirmation } from '@/base/AppAwaitableComponent.ts';
import { UrlUtil } from '@/lib/UrlUtil.ts';
type MangaToMigrate = NonNullable<GetMangaToMigrateQuery['manga']>;
type MangaToMigrateTo = NonNullable<GetMangaToMigrateToFetchMutation['fetchManga']>['manga'];
@@ -172,10 +173,12 @@ export class Mangas {
}
static getThumbnailUrl(manga: Partial<MangaThumbnailInfo>): string {
const thumbnailUrl = manga.thumbnailUrl
? `${manga.thumbnailUrl}?fetchedAt=${manga.thumbnailUrlLastFetched}`
: '';
return requestManager.getValidImgUrlFor(thumbnailUrl);
const url = UrlUtil.addParams(manga.thumbnailUrl ?? '', {
fetchedAt: manga.thumbnailUrlLastFetched,
sourceId: manga.sourceId,
});
return requestManager.getValidImgUrlFor(url);
}
static getDuplicateLibraryMangas(

View File

@@ -18,6 +18,8 @@ import {
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { TChapterReader } from '@/features/chapter/Chapter.types.ts';
import { ReaderChaptersStoreSlice } from '@/features/reader/stores/ReaderChaptersStore.ts';
import { getReaderStore } from '@/features/reader/stores/ReaderStore.ts';
import { UrlUtil } from '@/lib/UrlUtil.ts';
export const useReaderSetPagesState = (
isCurrentChapter: boolean,
@@ -48,7 +50,10 @@ export const useReaderSetPagesState = (
}
const { pages: pagesFromResponse } = pagesPayload;
const newPages = pagesFromResponse.length ? pagesFromResponse : [''];
const tmpPages = pagesFromResponse.length ? pagesFromResponse : [''];
const newPages = tmpPages.map((page) =>
UrlUtil.addParams(page, { sourceId: getReaderStore().manga?.sourceId }),
);
const initialReaderPageIndex = getInitialReaderPageIndex(resumeMode, lastPageRead ?? 0, newPages.length - 1);
const didPagesChange = previousPageData.current !== pagesPayload?.pages;

View File

@@ -38,6 +38,7 @@ export const ChapterUpdateCard = memo(({ chapter }: { chapter: ChapterUpdateList
<Box sx={{ display: 'flex', flexGrow: 1, gap: 1 }}>
<ChapterCardThumbnail
mangaId={manga.id}
sourceId={manga.sourceId}
mangaTitle={manga.title}
thumbnailUrl={manga.thumbnailUrl}
thumbnailUrlLastFetched={manga.thumbnailUrlLastFetched}