mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: adding articles for seeding and peers
This commit is contained in:
parent
90cb35db40
commit
52771d5a00
8 changed files with 58 additions and 25 deletions
|
@ -159,6 +159,8 @@ def action():
|
||||||
downloader = downloads.get(game_id)
|
downloader = downloads.get(game_id)
|
||||||
if downloader:
|
if downloader:
|
||||||
downloader.pause_download()
|
downloader.pause_download()
|
||||||
|
|
||||||
|
if downloading_game_id == game_id:
|
||||||
downloading_game_id = -1
|
downloading_game_id = -1
|
||||||
elif action == 'cancel':
|
elif action == 'cancel':
|
||||||
downloader = downloads.get(game_id)
|
downloader = downloads.get(game_id)
|
||||||
|
|
|
@ -13,7 +13,14 @@ const cancelGameDownload = async (
|
||||||
|
|
||||||
await DownloadManager.cancelDownload(downloadKey);
|
await DownloadManager.cancelDownload(downloadKey);
|
||||||
|
|
||||||
await downloadsSublevel.del(downloadKey);
|
const download = await downloadsSublevel.get(downloadKey);
|
||||||
|
|
||||||
|
if (!download) return;
|
||||||
|
|
||||||
|
await downloadsSublevel.put(downloadKey, {
|
||||||
|
...download,
|
||||||
|
status: "removed",
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
registerEvent("cancelGameDownload", cancelGameDownload);
|
registerEvent("cancelGameDownload", cancelGameDownload);
|
||||||
|
|
|
@ -219,8 +219,10 @@ export class DownloadManager {
|
||||||
} as PauseDownloadPayload)
|
} as PauseDownloadPayload)
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
WindowManager.mainWindow?.setProgressBar(-1);
|
if (downloadKey === this.downloadingGameId) {
|
||||||
this.downloadingGameId = null;
|
WindowManager.mainWindow?.setProgressBar(-1);
|
||||||
|
this.downloadingGameId = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async resumeDownload(download: Download) {
|
static async resumeDownload(download: Download) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ export function useDownload() {
|
||||||
const pauseDownload = async (shop: GameShop, objectId: string) => {
|
const pauseDownload = async (shop: GameShop, objectId: string) => {
|
||||||
await window.electron.pauseGameDownload(shop, objectId);
|
await window.electron.pauseGameDownload(shop, objectId);
|
||||||
await updateLibrary();
|
await updateLibrary();
|
||||||
dispatch(clearDownload());
|
if (lastPacket?.gameId === `${shop}:${objectId}`) dispatch(clearDownload());
|
||||||
};
|
};
|
||||||
|
|
||||||
const resumeDownload = async (shop: GameShop, objectId: string) => {
|
const resumeDownload = async (shop: GameShop, objectId: string) => {
|
||||||
|
|
|
@ -5,6 +5,14 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: calc(globals.$spacing-unit * 2);
|
gap: calc(globals.$spacing-unit * 2);
|
||||||
|
|
||||||
|
&__details-with-article {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: calc(globals.$spacing-unit / 2);
|
||||||
|
align-self: flex-start;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
&__header {
|
&__header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
DownloadIcon,
|
DownloadIcon,
|
||||||
LinkIcon,
|
LinkIcon,
|
||||||
PlayIcon,
|
PlayIcon,
|
||||||
|
QuestionIcon,
|
||||||
ThreeBarsIcon,
|
ThreeBarsIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
UnlinkIcon,
|
UnlinkIcon,
|
||||||
|
@ -122,8 +123,12 @@ export function DownloadGroup({
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{download.downloader === Downloader.Torrent && (
|
{download.downloader === Downloader.Torrent && (
|
||||||
<small>
|
<small
|
||||||
|
className="download-group__details-with-article"
|
||||||
|
data-open-article="peers-and-seeds"
|
||||||
|
>
|
||||||
{lastPacket?.numPeers} peers / {lastPacket?.numSeeds} seeds
|
{lastPacket?.numPeers} peers / {lastPacket?.numSeeds} seeds
|
||||||
|
<QuestionIcon size={12} />
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -136,7 +141,14 @@ export function DownloadGroup({
|
||||||
return download.status === "seeding" &&
|
return download.status === "seeding" &&
|
||||||
download.downloader === Downloader.Torrent ? (
|
download.downloader === Downloader.Torrent ? (
|
||||||
<>
|
<>
|
||||||
<p>{t("seeding")}</p>
|
<p
|
||||||
|
data-open-article="seeding"
|
||||||
|
className="download-group__details-with-article"
|
||||||
|
>
|
||||||
|
{t("seeding")}
|
||||||
|
|
||||||
|
<QuestionIcon />
|
||||||
|
</p>
|
||||||
{uploadSpeed && <p>{uploadSpeed}/s</p>}
|
{uploadSpeed && <p>{uploadSpeed}/s</p>}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
@ -217,7 +229,7 @@ export function DownloadGroup({
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGameDownloading || download?.status === "active") {
|
if (isGameDownloading) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
label: t("pause"),
|
label: t("pause"),
|
||||||
|
|
|
@ -8,7 +8,7 @@ import "./downloads.scss";
|
||||||
import { DeleteGameModal } from "./delete-game-modal";
|
import { DeleteGameModal } from "./delete-game-modal";
|
||||||
import { DownloadGroup } from "./download-group";
|
import { DownloadGroup } from "./download-group";
|
||||||
import type { GameShop, LibraryGame, SeedingStatus } from "@types";
|
import type { GameShop, LibraryGame, SeedingStatus } from "@types";
|
||||||
import { orderBy, sortBy } from "lodash-es";
|
import { orderBy } from "lodash-es";
|
||||||
import { ArrowDownIcon } from "@primer/octicons-react";
|
import { ArrowDownIcon } from "@primer/octicons-react";
|
||||||
|
|
||||||
export default function Downloads() {
|
export default function Downloads() {
|
||||||
|
@ -58,24 +58,24 @@ export default function Downloads() {
|
||||||
complete: [],
|
complete: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = sortBy(library, (game) => game.download?.timestamp).reduce(
|
const result = orderBy(
|
||||||
(prev, next) => {
|
library,
|
||||||
/* Game has been manually added to the library or has been canceled */
|
(game) => game.download?.timestamp,
|
||||||
if (!next.download?.status || next.download?.status === "removed")
|
"desc"
|
||||||
return prev;
|
).reduce((prev, next) => {
|
||||||
|
/* Game has been manually added to the library */
|
||||||
|
if (!next.download) return prev;
|
||||||
|
|
||||||
/* Is downloading */
|
/* Is downloading */
|
||||||
if (lastPacket?.gameId === next.id)
|
if (lastPacket?.gameId === next.id)
|
||||||
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.queued || 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] };
|
||||||
},
|
}, initialValue);
|
||||||
initialValue
|
|
||||||
);
|
|
||||||
|
|
||||||
const queued = orderBy(result.queued, (game) => game.download?.timestamp, [
|
const queued = orderBy(result.queued, (game) => game.download?.timestamp, [
|
||||||
"desc",
|
"desc",
|
||||||
|
|
|
@ -163,8 +163,10 @@ export function DownloadSettingsModal({
|
||||||
selectedDownloader === downloader ? "primary" : "outline"
|
selectedDownloader === downloader ? "primary" : "outline"
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
downloader === Downloader.RealDebrid &&
|
(downloader === Downloader.RealDebrid &&
|
||||||
!userPreferences?.realDebridApiToken
|
!userPreferences?.realDebridApiToken) ||
|
||||||
|
(downloader === Downloader.TorBox &&
|
||||||
|
!userPreferences?.torBoxApiToken)
|
||||||
}
|
}
|
||||||
onClick={() => setSelectedDownloader(downloader)}
|
onClick={() => setSelectedDownloader(downloader)}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Reference in a new issue