mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-13 03:32:13 +00:00
fix: adding sorting to download list
This commit is contained in:
parent
73b4b2c13c
commit
588cb983c2
2 changed files with 20 additions and 9 deletions
|
@ -11,7 +11,7 @@ import {
|
||||||
|
|
||||||
import { Downloader, formatBytes } from "@shared";
|
import { Downloader, formatBytes } from "@shared";
|
||||||
import { DOWNLOADER_NAME } from "@renderer/constants";
|
import { DOWNLOADER_NAME } from "@renderer/constants";
|
||||||
import { useAppSelector, useDownload } from "@renderer/hooks";
|
import { useAppSelector, useDownload, useLibrary } from "@renderer/hooks";
|
||||||
|
|
||||||
import * as styles from "./download-list.css";
|
import * as styles from "./download-list.css";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -25,6 +25,8 @@ export function DownloadList({ library }: DownloadListProps) {
|
||||||
|
|
||||||
const { t } = useTranslation("downloads");
|
const { t } = useTranslation("downloads");
|
||||||
|
|
||||||
|
const { updateLibrary } = useLibrary();
|
||||||
|
|
||||||
const userPreferences = useAppSelector(
|
const userPreferences = useAppSelector(
|
||||||
(state) => state.userPreferences.value
|
(state) => state.userPreferences.value
|
||||||
);
|
);
|
||||||
|
@ -42,8 +44,8 @@ export function DownloadList({ library }: DownloadListProps) {
|
||||||
|
|
||||||
const openGameInstaller = (gameId: number) =>
|
const openGameInstaller = (gameId: number) =>
|
||||||
window.electron.openGameInstaller(gameId).then((isBinaryInPath) => {
|
window.electron.openGameInstaller(gameId).then((isBinaryInPath) => {
|
||||||
// if (!isBinaryInPath) setShowBinaryNotFoundModal(true);
|
if (!isBinaryInPath) setShowBinaryNotFoundModal(true);
|
||||||
// updateLibrary();
|
updateLibrary();
|
||||||
});
|
});
|
||||||
|
|
||||||
const getFinalDownloadSize = (game: LibraryGame) => {
|
const getFinalDownloadSize = (game: LibraryGame) => {
|
||||||
|
@ -92,7 +94,7 @@ export function DownloadList({ library }: DownloadListProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>{formatDownloadProgress(game.progress)}</p>
|
<p>{formatDownloadProgress(game.progress)}</p>
|
||||||
<p>{t(game.downloadQueue ? "queued" : "paused")}</p>
|
<p>{t(game.downloadQueue && lastPacket ? "queued" : "paused")}</p>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { LibraryGame } from "@types";
|
||||||
import { orderBy } from "lodash-es";
|
import { orderBy } from "lodash-es";
|
||||||
|
|
||||||
export function Downloads() {
|
export function Downloads() {
|
||||||
const { library, updateLibrary } = useLibrary();
|
const { library } = useLibrary();
|
||||||
|
|
||||||
const { t } = useTranslation("downloads");
|
const { t } = useTranslation("downloads");
|
||||||
|
|
||||||
|
@ -41,18 +41,27 @@ export function Downloads() {
|
||||||
return { ...prev, downloading: [...prev.downloading, next] };
|
return { ...prev, downloading: [...prev.downloading, next] };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next.downloadQueue) {
|
if (next.downloadQueue || next.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] };
|
||||||
}, initialValue);
|
}, initialValue);
|
||||||
|
|
||||||
|
const queued = orderBy(
|
||||||
|
result.queued,
|
||||||
|
(game) => game.downloadQueue?.id ?? -1,
|
||||||
|
["desc"]
|
||||||
|
);
|
||||||
|
|
||||||
|
const complete = orderBy(result.complete, (game) =>
|
||||||
|
game.status === "complete" ? 0 : 1
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
queued: orderBy(result.queued, (game) => game.downloadQueue?.id, [
|
queued,
|
||||||
"desc",
|
complete,
|
||||||
]),
|
|
||||||
};
|
};
|
||||||
}, [library, lastPacket?.game.id]);
|
}, [library, lastPacket?.game.id]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue