mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-12 11:12:07 +00:00
fix: reset lastPacket on signout
This commit is contained in:
parent
2e85363966
commit
34e439bd66
12 changed files with 34 additions and 28 deletions
|
@ -46,9 +46,9 @@ const addGameToLibrary = async (
|
|||
|
||||
await gamesSublevel.put(levelKeys.game(shop, objectId), game);
|
||||
|
||||
updateLocalUnlockedAchivements(game!);
|
||||
updateLocalUnlockedAchivements(game);
|
||||
|
||||
createGame(game!).catch(() => {});
|
||||
createGame(game).catch(() => {});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
export { db } from "./level";
|
||||
|
||||
export * from "./sublevels";
|
||||
|
|
|
@ -2,5 +2,4 @@ export * from "./downloads";
|
|||
export * from "./games";
|
||||
export * from "./game-shop-cache";
|
||||
export * from "./game-achievements";
|
||||
|
||||
export * from "./keys";
|
||||
|
|
|
@ -234,6 +234,8 @@ export class DownloadManager {
|
|||
});
|
||||
|
||||
WindowManager.mainWindow?.setProgressBar(-1);
|
||||
WindowManager.mainWindow?.webContents.send("on-download-progress", null);
|
||||
|
||||
if (downloadKey === this.downloadingGameId) {
|
||||
this.downloadingGameId = null;
|
||||
}
|
||||
|
|
|
@ -35,22 +35,20 @@ export const mergeWithRemoteGames = async () => {
|
|||
name: "getById",
|
||||
});
|
||||
|
||||
if (steamGame) {
|
||||
const iconUrl = steamGame?.clientIcon
|
||||
? steamUrlBuilder.icon(game.objectId, steamGame.clientIcon)
|
||||
: null;
|
||||
const iconUrl = steamGame?.clientIcon
|
||||
? steamUrlBuilder.icon(game.objectId, steamGame.clientIcon)
|
||||
: null;
|
||||
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
objectId: game.objectId,
|
||||
title: steamGame?.name,
|
||||
remoteId: game.id,
|
||||
shop: game.shop,
|
||||
iconUrl,
|
||||
lastTimePlayed: game.lastTimePlayed,
|
||||
playTimeInMilliseconds: game.playTimeInMilliseconds,
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
gamesSublevel.put(levelKeys.game(game.shop, game.objectId), {
|
||||
objectId: game.objectId,
|
||||
title: steamGame?.name,
|
||||
remoteId: game.id,
|
||||
shop: game.shop,
|
||||
iconUrl,
|
||||
lastTimePlayed: game.lastTimePlayed,
|
||||
playTimeInMilliseconds: game.playTimeInMilliseconds,
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -21,11 +21,18 @@ export const getSteamAppDetails = async (
|
|||
});
|
||||
|
||||
return axios
|
||||
.get(
|
||||
.get<SteamAppDetailsResponse>(
|
||||
`http://store.steampowered.com/api/appdetails?${searchParams.toString()}`
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.data[objectId].success) return response.data[objectId].data;
|
||||
if (response.data[objectId].success) {
|
||||
const data = response.data[objectId].data;
|
||||
return {
|
||||
...data,
|
||||
objectId,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
@ -32,10 +32,10 @@ contextBridge.exposeInMainWorld("electron", {
|
|||
ipcRenderer.invoke("pauseGameSeed", shop, objectId),
|
||||
resumeGameSeed: (shop: GameShop, objectId: string) =>
|
||||
ipcRenderer.invoke("resumeGameSeed", shop, objectId),
|
||||
onDownloadProgress: (cb: (value: DownloadProgress) => void) => {
|
||||
onDownloadProgress: (cb: (value: DownloadProgress | null) => void) => {
|
||||
const listener = (
|
||||
_event: Electron.IpcRendererEvent,
|
||||
value: DownloadProgress
|
||||
value: DownloadProgress | null
|
||||
) => cb(value);
|
||||
ipcRenderer.on("on-download-progress", listener);
|
||||
return () => ipcRenderer.removeListener("on-download-progress", listener);
|
||||
|
|
|
@ -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;
|
||||
|
|
2
src/renderer/src/declaration.d.ts
vendored
2
src/renderer/src/declaration.d.ts
vendored
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -114,7 +114,7 @@ export function useDownload() {
|
|||
pauseSeeding,
|
||||
resumeSeeding,
|
||||
clearDownload: () => dispatch(clearDownload()),
|
||||
setLastPacket: (packet: DownloadProgress) =>
|
||||
setLastPacket: (packet: DownloadProgress | null) =>
|
||||
dispatch(setLastPacket(packet)),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ export interface SteamMovies {
|
|||
|
||||
export interface SteamAppDetails {
|
||||
name: string;
|
||||
steam_appid: number;
|
||||
detailed_description: string;
|
||||
about_the_game: string;
|
||||
short_description: string;
|
||||
|
|
Loading…
Reference in a new issue