fix: reset lastPacket on signout

This commit is contained in:
Zamitto
2025-02-02 20:15:27 -03:00
parent 2e85363966
commit 34e439bd66
12 changed files with 34 additions and 28 deletions

View File

@@ -84,7 +84,7 @@ export function App() {
useEffect(() => {
const unsubscribe = window.electron.onDownloadProgress(
(downloadProgress) => {
if (downloadProgress.progress === 1) {
if (downloadProgress?.progress === 1) {
clearDownload();
updateLibrary();
return;

View File

@@ -50,7 +50,7 @@ declare global {
pauseGameSeed: (shop: GameShop, objectId: string) => Promise<void>;
resumeGameSeed: (shop: GameShop, objectId: string) => Promise<void>;
onDownloadProgress: (
cb: (value: DownloadProgress) => void
cb: (value: DownloadProgress | null) => void
) => () => Electron.IpcRenderer;
onSeedingStatus: (
cb: (value: SeedingStatus[]) => void

View File

@@ -18,9 +18,9 @@ export const downloadSlice = createSlice({
name: "download",
initialState,
reducers: {
setLastPacket: (state, action: PayloadAction<DownloadProgress>) => {
setLastPacket: (state, action: PayloadAction<DownloadProgress | null>) => {
state.lastPacket = action.payload;
if (!state.gameId) state.gameId = action.payload.gameId;
if (!state.gameId && action.payload) state.gameId = action.payload.gameId;
},
clearDownload: (state) => {
state.lastPacket = null;

View File

@@ -114,7 +114,7 @@ export function useDownload() {
pauseSeeding,
resumeSeeding,
clearDownload: () => dispatch(clearDownload()),
setLastPacket: (packet: DownloadProgress) =>
setLastPacket: (packet: DownloadProgress | null) =>
dispatch(setLastPacket(packet)),
};
}