mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +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, {
|
||||
...download,
|
||||
status: "paused",
|
||||
queued: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -31,6 +31,7 @@ const resumeGameDownload = async (
|
||||
...download,
|
||||
status: "active",
|
||||
timestamp: Date.now(),
|
||||
queued: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -72,6 +72,7 @@ const startGameDownload = async (
|
||||
fileSize: null,
|
||||
shouldSeed: false,
|
||||
timestamp: Date.now(),
|
||||
queued: true,
|
||||
};
|
||||
|
||||
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 { HydraApi } from "./services/hydra-api";
|
||||
import { uploadGamesBatch } from "./services/library-sync";
|
||||
@ -34,7 +40,11 @@ const loadState = async (userPreferences: UserPreferences | null) => {
|
||||
.values()
|
||||
.all()
|
||||
.then((games) => {
|
||||
return sortBy(games, "timestamp", "DESC");
|
||||
return sortBy(
|
||||
games.filter((game) => game.queued),
|
||||
"timestamp",
|
||||
"DESC"
|
||||
);
|
||||
});
|
||||
|
||||
const [nextItemOnQueue] = downloads;
|
||||
@ -137,8 +147,8 @@ const migrateFromSqlite = async () => {
|
||||
await db.put<string, Auth>(
|
||||
levelKeys.auth,
|
||||
{
|
||||
accessToken: users[0].accessToken,
|
||||
refreshToken: users[0].refreshToken,
|
||||
accessToken: Crypto.encrypt(users[0].accessToken),
|
||||
refreshToken: Crypto.encrypt(users[0].refreshToken),
|
||||
tokenExpirationTimestamp: users[0].tokenExpirationTimestamp,
|
||||
},
|
||||
{
|
||||
|
@ -137,12 +137,14 @@ export class DownloadManager {
|
||||
...download,
|
||||
status: "seeding",
|
||||
shouldSeed: true,
|
||||
queued: false,
|
||||
});
|
||||
} else {
|
||||
downloadsSublevel.put(gameId, {
|
||||
...download,
|
||||
status: "complete",
|
||||
shouldSeed: false,
|
||||
queued: false,
|
||||
});
|
||||
|
||||
this.cancelDownload(gameId);
|
||||
@ -153,9 +155,7 @@ export class DownloadManager {
|
||||
.all()
|
||||
.then((games) => {
|
||||
return sortBy(
|
||||
games.filter(
|
||||
(game) => !["complete", "seeding"].includes(game.status!)
|
||||
),
|
||||
games.filter((game) => game.status === "paused" && game.queued),
|
||||
"timestamp",
|
||||
"DESC"
|
||||
);
|
||||
|
@ -125,12 +125,11 @@ export function Sidebar() {
|
||||
});
|
||||
}
|
||||
|
||||
if (game.download?.queued) return t("queued", { title: game.title });
|
||||
|
||||
if (game.download?.status === "paused")
|
||||
return t("paused", { title: game.title });
|
||||
|
||||
if (game.download?.status === "active")
|
||||
return t("queued", { title: game.title });
|
||||
|
||||
return game.title;
|
||||
};
|
||||
|
||||
|
@ -150,7 +150,7 @@ export function DownloadGroup({
|
||||
return (
|
||||
<>
|
||||
<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] };
|
||||
|
||||
/* 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, complete: [...prev.complete, next] };
|
||||
|
@ -56,6 +56,7 @@ export interface Download {
|
||||
fileSize: number | null;
|
||||
shouldSeed: boolean;
|
||||
status: DownloadStatus | null;
|
||||
queued: boolean;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user