mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 22:06:17 +00:00
fix: remove unused peak speed update dispatch in DownloadGroup component
This commit is contained in:
@@ -30,6 +30,15 @@ export const downloadSlice = createSlice({
|
||||
setLastPacket: (state, action: PayloadAction<DownloadProgress | null>) => {
|
||||
state.lastPacket = action.payload;
|
||||
if (!state.gameId && action.payload) state.gameId = action.payload.gameId;
|
||||
|
||||
// Track peak speed atomically when packet arrives
|
||||
if (action.payload?.gameId && action.payload.downloadSpeed != null) {
|
||||
const { gameId, downloadSpeed } = action.payload;
|
||||
const currentPeak = state.peakSpeeds[gameId] || 0;
|
||||
if (downloadSpeed > currentPeak) {
|
||||
state.peakSpeeds[gameId] = downloadSpeed;
|
||||
}
|
||||
}
|
||||
},
|
||||
clearDownload: (state) => {
|
||||
state.lastPacket = null;
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
useLibrary,
|
||||
useDate,
|
||||
} from "@renderer/hooks";
|
||||
import { updatePeakSpeed, clearPeakSpeed } from "@renderer/features";
|
||||
import { clearPeakSpeed } from "@renderer/features";
|
||||
|
||||
import "./download-group.scss";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -585,8 +585,6 @@ export function DownloadGroup({
|
||||
const gameId = lastPacket.gameId;
|
||||
const downloadSpeed = lastPacket.downloadSpeed;
|
||||
|
||||
dispatch(updatePeakSpeed({ gameId, speed: downloadSpeed }));
|
||||
|
||||
if (!speedHistoryRef.current[gameId]) {
|
||||
speedHistoryRef.current[gameId] = [];
|
||||
}
|
||||
@@ -596,7 +594,7 @@ export function DownloadGroup({
|
||||
if (speedHistoryRef.current[gameId].length > 120) {
|
||||
speedHistoryRef.current[gameId].shift();
|
||||
}
|
||||
}, [lastPacket, dispatch]);
|
||||
}, [lastPacket]);
|
||||
|
||||
useEffect(() => {
|
||||
for (const game of library) {
|
||||
|
||||
Reference in New Issue
Block a user