feat: adding authorization to rpc

This commit is contained in:
Chubby Granny Chaser 2024-06-28 12:03:01 +01:00
parent 96e96cd8aa
commit 363bcf16a4
No known key found for this signature in database
6 changed files with 166 additions and 49 deletions

View file

@ -22,13 +22,14 @@ export function useDownload() {
);
const dispatch = useAppDispatch();
const startDownload = (payload: StartGameDownloadPayload) =>
const startDownload = (payload: StartGameDownloadPayload) => {
dispatch(clearDownload());
window.electron.startGameDownload(payload).then((game) => {
dispatch(clearDownload());
updateLibrary();
return game;
});
};
const pauseDownload = async (gameId: number) => {
await window.electron.pauseGameDownload(gameId);
@ -65,7 +66,7 @@ export function useDownload() {
updateLibrary();
});
const getETA = () => {
const calculateETA = () => {
if (!lastPacket || lastPacket.timeRemaining < 0) return "";
try {
@ -87,7 +88,7 @@ export function useDownload() {
downloadSpeed: `${formatBytes(lastPacket?.downloadSpeed ?? 0)}/s`,
progress: formatDownloadProgress(lastPacket?.progress ?? 0),
lastPacket,
eta: getETA(),
eta: calculateETA(),
startDownload,
pauseDownload,
resumeDownload,