mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
remove duplicity and simplify AppUpdaterEvent
This commit is contained in:
parent
b742a464c9
commit
7ebd91a652
@ -1,4 +1,4 @@
|
||||
import { AppUpdaterEvents } from "@types";
|
||||
import { AppUpdaterEvent } from "@types";
|
||||
import { registerEvent } from "../register-event";
|
||||
import updater, { UpdateInfo } from "electron-updater";
|
||||
import { WindowManager } from "@main/services";
|
||||
@ -6,7 +6,7 @@ import { app } from "electron";
|
||||
|
||||
const { autoUpdater } = updater;
|
||||
|
||||
const sendEvent = (event: AppUpdaterEvents) => {
|
||||
const sendEvent = (event: AppUpdaterEvent) => {
|
||||
WindowManager.mainWindow?.webContents.send("autoUpdaterEvent", event);
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
|
||||
import { SyncIcon } from "@primer/octicons-react";
|
||||
import { Link } from "../link/link";
|
||||
import * as styles from "./header.css";
|
||||
import { AppUpdaterEvents } from "@types";
|
||||
import { AppUpdaterEvent } from "@types";
|
||||
|
||||
export const releasesPageUrl =
|
||||
"https://github.com/hydralauncher/hydra/releases";
|
||||
@ -16,15 +16,15 @@ export function AutoUpdateSubHeader() {
|
||||
|
||||
const { t } = useTranslation("header");
|
||||
|
||||
const handleClickNewUpdate = () => {
|
||||
const handleClickInstallUpdate = () => {
|
||||
window.electron.restartAndInstallUpdate();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = window.electron.onAutoUpdaterEvent(
|
||||
(event: AppUpdaterEvents) => {
|
||||
(event: AppUpdaterEvent) => {
|
||||
if (event.type == "update-available") {
|
||||
setNewVersion(event.info.version || "");
|
||||
setNewVersion(event.info.version);
|
||||
|
||||
if (isMac) {
|
||||
setShowUpdateSubheader(true);
|
||||
@ -59,7 +59,7 @@ export function AutoUpdateSubHeader() {
|
||||
<button
|
||||
type="button"
|
||||
className={styles.newVersionButton}
|
||||
onClick={handleClickNewUpdate}
|
||||
onClick={handleClickInstallUpdate}
|
||||
>
|
||||
<SyncIcon size={12} />
|
||||
<small>
|
||||
|
4
src/renderer/src/declaration.d.ts
vendored
4
src/renderer/src/declaration.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
import type {
|
||||
AppUpdaterEvents,
|
||||
AppUpdaterEvent,
|
||||
CatalogueCategory,
|
||||
CatalogueEntry,
|
||||
Game,
|
||||
@ -92,7 +92,7 @@ declare global {
|
||||
|
||||
/* Auto update */
|
||||
onAutoUpdaterEvent: (
|
||||
cb: (event: AppUpdaterEvents) => void
|
||||
cb: (event: AppUpdaterEvent) => void
|
||||
) => () => Electron.IpcRenderer;
|
||||
checkForUpdates: () => Promise<void>;
|
||||
restartAndInstallUpdate: () => Promise<void>;
|
||||
|
@ -1,6 +1,5 @@
|
||||
import type { Aria2Status } from "aria2";
|
||||
import type { Downloader } from "@shared";
|
||||
import { ProgressInfo, UpdateInfo } from "electron-updater";
|
||||
|
||||
export type GameShop = "steam" | "epic";
|
||||
export type CatalogueCategory = "recently_added" | "trending";
|
||||
@ -146,13 +145,8 @@ export interface SteamGame {
|
||||
}
|
||||
|
||||
export type AppUpdaterEvent =
|
||||
| { type: "error" }
|
||||
| { type: "checking-for-updates" }
|
||||
| { type: "update-not-available" }
|
||||
| { type: "update-available"; info: UpdateInfo }
|
||||
| { type: "update-downloaded" }
|
||||
| { type: "download-progress"; info: ProgressInfo }
|
||||
| { type: "update-cancelled" };
|
||||
| { type: "update-available"; info: { version: string } }
|
||||
| { type: "update-downloaded" };
|
||||
|
||||
/* Events */
|
||||
export interface StartGameDownloadPayload {
|
||||
@ -230,6 +224,3 @@ export interface RealDebridUser {
|
||||
premium: number;
|
||||
expiration: string;
|
||||
}
|
||||
export type AppUpdaterEvents =
|
||||
| { type: "update-available"; info: Partial<UpdateInfo> }
|
||||
| { type: "update-downloaded" };
|
||||
|
Loading…
Reference in New Issue
Block a user