Update to server download subscription changes

This commit is contained in:
schroda
2024-08-21 21:29:01 +02:00
parent 61ae717e9a
commit a819d45489
9 changed files with 217 additions and 42 deletions

View File

@@ -57,7 +57,7 @@ export const DownloadStateIndicator = ({ download }: { download: ChapterDownload
}}
>
<>
{isDownloading && `${Math.round(download.progress * 100)}%`}
{(isDownloading || isPartiallyDownloaded) && `${Math.round(download.progress * 100)}%`}
{!isDownloading &&
!isPartiallyDownloaded &&
t(DOWNLOAD_STATE_TO_TRANSLATION_KEY_MAP[download.state])}

View File

@@ -34,7 +34,7 @@ import { NavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.t
import { LoadingPlaceholder } from '@/modules/core/components/placeholder/LoadingPlaceholder.tsx';
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import { ChapterDownloadStatus, ChapterIdInfo } from '@/modules/chapter/services/Chapters.ts';
import { DownloadState } from '@/lib/graphql/generated/graphql.ts';
import { DownloaderState, DownloadState } from '@/lib/graphql/generated/graphql.ts';
const HeightPreservingItem = ({ children, ...props }: BoxProps) => (
// the height is necessary to prevent the item container from collapsing, which confuses Virtuoso measurements
@@ -145,7 +145,7 @@ export const DownloadQueue: React.FC = () => {
};
const toggleQueueStatus = () => {
if (status === 'STOPPED') {
if (status === DownloaderState.Stopped) {
requestManager.startDownloads();
} else {
requestManager.stopDownloads();
@@ -162,9 +162,9 @@ export const DownloadQueue: React.FC = () => {
</IconButton>
</Tooltip>
<Tooltip title={t(status === 'STOPPED' ? 'global.button.start' : 'global.button.stop')}>
<Tooltip title={t(status === DownloaderState.Started ? 'global.button.start' : 'global.button.stop')}>
<IconButton onClick={toggleQueueStatus} size="large" disabled={isQueueEmpty} color="inherit">
{status === 'STOPPED' ? <PlayArrowIcon /> : <PauseIcon />}
{status === DownloaderState.Stopped ? <PlayArrowIcon /> : <PauseIcon />}
</IconButton>
</Tooltip>
</>,
@@ -220,7 +220,7 @@ export const DownloadQueue: React.FC = () => {
};
const handleDelete = async (chapter: ChapterIdInfo) => {
const isRunning = status === 'STARTED';
const isRunning = status === DownloaderState.Started;
try {
if (isRunning) {
@@ -287,9 +287,9 @@ export const DownloadQueue: React.FC = () => {
components={{
Item: HeightPreservingItem,
}}
computeItemKey={(_, item) => item.manga.id}
computeItemKey={(_, item) => item.chapter.id}
itemContent={(index, item) => (
<Draggable draggableId={`${item.manga.id}-${item.chapter.sourceOrder}`} index={index}>
<Draggable draggableId={`${item.chapter.id}`} index={index}>
{(draggableProvided) => (
<DownloadChapterItem
provided={draggableProvided}