feat: process watcher send list of running process

This commit is contained in:
Zamitto 2024-06-19 14:37:26 -03:00
parent e56a8209e1
commit e933cec888
4 changed files with 22 additions and 27 deletions

View file

@ -110,14 +110,14 @@ export function GameDetailsContextProvider({
useEffect(() => {
const listeners = [
window.electron.onGameClose(() => {
if (isGameRunning) setisGameRunning(false);
}),
window.electron.onPlaytime((gameId) => {
if (gameId === game?.id) {
if (!isGameRunning) setisGameRunning(true);
window.electron.onGamesRunning((gamesIds) => {
const newIsGameRunning = !!game?.id && gamesIds.includes(game.id);
if (isGameRunning != newIsGameRunning) {
updateGame();
}
setisGameRunning(newIsGameRunning);
}),
];

View file

@ -71,8 +71,9 @@ declare global {
removeGame: (gameId: number) => Promise<void>;
deleteGameFolder: (gameId: number) => Promise<unknown>;
getGameByObjectID: (objectID: string) => Promise<Game | null>;
onPlaytime: (cb: (gameId: number) => void) => () => Electron.IpcRenderer;
onGameClose: (cb: (gameId: number) => void) => () => Electron.IpcRenderer;
onGamesRunning: (
cb: (gamesId: number[]) => void
) => () => Electron.IpcRenderer;
/* User preferences */
getUserPreferences: () => Promise<UserPreferences | null>;