mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
chore: improving download queue
This commit is contained in:
parent
f387560836
commit
549481f85a
@ -19,6 +19,7 @@ const pauseGameDownload = async (
|
|||||||
await downloadsSublevel.put(gameKey, {
|
await downloadsSublevel.put(gameKey, {
|
||||||
...download,
|
...download,
|
||||||
status: "paused",
|
status: "paused",
|
||||||
|
queued: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,7 @@ const resumeGameDownload = async (
|
|||||||
...download,
|
...download,
|
||||||
status: "active",
|
status: "active",
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
|
queued: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -72,6 +72,7 @@ const startGameDownload = async (
|
|||||||
fileSize: null,
|
fileSize: null,
|
||||||
shouldSeed: false,
|
shouldSeed: false,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
|
queued: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
await downloadsSublevel.put(gameKey, download);
|
await downloadsSublevel.put(gameKey, download);
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
import { DownloadManager, logger, Ludusavi, startMainLoop } from "./services";
|
import {
|
||||||
|
Crypto,
|
||||||
|
DownloadManager,
|
||||||
|
logger,
|
||||||
|
Ludusavi,
|
||||||
|
startMainLoop,
|
||||||
|
} from "./services";
|
||||||
import { RealDebridClient } from "./services/download/real-debrid";
|
import { RealDebridClient } from "./services/download/real-debrid";
|
||||||
import { HydraApi } from "./services/hydra-api";
|
import { HydraApi } from "./services/hydra-api";
|
||||||
import { uploadGamesBatch } from "./services/library-sync";
|
import { uploadGamesBatch } from "./services/library-sync";
|
||||||
@ -34,7 +40,11 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
|||||||
.values()
|
.values()
|
||||||
.all()
|
.all()
|
||||||
.then((games) => {
|
.then((games) => {
|
||||||
return sortBy(games, "timestamp", "DESC");
|
return sortBy(
|
||||||
|
games.filter((game) => game.queued),
|
||||||
|
"timestamp",
|
||||||
|
"DESC"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const [nextItemOnQueue] = downloads;
|
const [nextItemOnQueue] = downloads;
|
||||||
@ -137,8 +147,8 @@ const migrateFromSqlite = async () => {
|
|||||||
await db.put<string, Auth>(
|
await db.put<string, Auth>(
|
||||||
levelKeys.auth,
|
levelKeys.auth,
|
||||||
{
|
{
|
||||||
accessToken: users[0].accessToken,
|
accessToken: Crypto.encrypt(users[0].accessToken),
|
||||||
refreshToken: users[0].refreshToken,
|
refreshToken: Crypto.encrypt(users[0].refreshToken),
|
||||||
tokenExpirationTimestamp: users[0].tokenExpirationTimestamp,
|
tokenExpirationTimestamp: users[0].tokenExpirationTimestamp,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -137,12 +137,14 @@ export class DownloadManager {
|
|||||||
...download,
|
...download,
|
||||||
status: "seeding",
|
status: "seeding",
|
||||||
shouldSeed: true,
|
shouldSeed: true,
|
||||||
|
queued: false,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
downloadsSublevel.put(gameId, {
|
downloadsSublevel.put(gameId, {
|
||||||
...download,
|
...download,
|
||||||
status: "complete",
|
status: "complete",
|
||||||
shouldSeed: false,
|
shouldSeed: false,
|
||||||
|
queued: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cancelDownload(gameId);
|
this.cancelDownload(gameId);
|
||||||
@ -153,9 +155,7 @@ export class DownloadManager {
|
|||||||
.all()
|
.all()
|
||||||
.then((games) => {
|
.then((games) => {
|
||||||
return sortBy(
|
return sortBy(
|
||||||
games.filter(
|
games.filter((game) => game.status === "paused" && game.queued),
|
||||||
(game) => !["complete", "seeding"].includes(game.status!)
|
|
||||||
),
|
|
||||||
"timestamp",
|
"timestamp",
|
||||||
"DESC"
|
"DESC"
|
||||||
);
|
);
|
||||||
|
@ -125,12 +125,11 @@ export function Sidebar() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.download?.queued) return t("queued", { title: game.title });
|
||||||
|
|
||||||
if (game.download?.status === "paused")
|
if (game.download?.status === "paused")
|
||||||
return t("paused", { title: game.title });
|
return t("paused", { title: game.title });
|
||||||
|
|
||||||
if (game.download?.status === "active")
|
|
||||||
return t("queued", { title: game.title });
|
|
||||||
|
|
||||||
return game.title;
|
return game.title;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ export function DownloadGroup({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>{formatDownloadProgress(download.progress)}</p>
|
<p>{formatDownloadProgress(download.progress)}</p>
|
||||||
{/* <p>{t(game.downloadQueue && lastPacket ? "queued" : "paused")}</p> */}
|
<p>{t(download.queued ? "queued" : "paused")}</p>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ export default function Downloads() {
|
|||||||
return { ...prev, downloading: [...prev.downloading, next] };
|
return { ...prev, downloading: [...prev.downloading, next] };
|
||||||
|
|
||||||
/* Is either queued or paused */
|
/* Is either queued or paused */
|
||||||
if (next.download?.status === "paused")
|
if (next.download.queued || next.download?.status === "paused")
|
||||||
return { ...prev, queued: [...prev.queued, next] };
|
return { ...prev, queued: [...prev.queued, next] };
|
||||||
|
|
||||||
return { ...prev, complete: [...prev.complete, next] };
|
return { ...prev, complete: [...prev.complete, next] };
|
||||||
|
@ -56,6 +56,7 @@ export interface Download {
|
|||||||
fileSize: number | null;
|
fileSize: number | null;
|
||||||
shouldSeed: boolean;
|
shouldSeed: boolean;
|
||||||
status: DownloadStatus | null;
|
status: DownloadStatus | null;
|
||||||
|
queued: boolean;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user