mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
Merge pull request #768 from hydralauncher/hyd-229-improve-visibility-of-update-message
feat: add color to update icon and notify when update is ready to install
This commit is contained in:
commit
be48306ca2
@ -199,7 +199,9 @@
|
|||||||
"game_ready_to_install": "{{title}} is ready to install",
|
"game_ready_to_install": "{{title}} is ready to install",
|
||||||
"repack_list_updated": "Repack list updated",
|
"repack_list_updated": "Repack list updated",
|
||||||
"repack_count_one": "{{count}} repack added",
|
"repack_count_one": "{{count}} repack added",
|
||||||
"repack_count_other": "{{count}} repacks added"
|
"repack_count_other": "{{count}} repacks added",
|
||||||
|
"new_update_available": "Version {{version}} available",
|
||||||
|
"restart_to_install_update": "Restart Hydra to install the update"
|
||||||
},
|
},
|
||||||
"system_tray": {
|
"system_tray": {
|
||||||
"open": "Open Hydra",
|
"open": "Open Hydra",
|
||||||
|
@ -199,7 +199,8 @@
|
|||||||
"game_ready_to_install": "{{title}} está listo para instalarse",
|
"game_ready_to_install": "{{title}} está listo para instalarse",
|
||||||
"repack_list_updated": "Lista de repacks actualizadas",
|
"repack_list_updated": "Lista de repacks actualizadas",
|
||||||
"repack_count_one": "{{count}} repack ha sido añadido",
|
"repack_count_one": "{{count}} repack ha sido añadido",
|
||||||
"repack_count_other": "{{count}} repacks añadidos"
|
"repack_count_other": "{{count}} repacks añadidos",
|
||||||
|
"new_update_available": "Version {{version}} disponible"
|
||||||
},
|
},
|
||||||
"system_tray": {
|
"system_tray": {
|
||||||
"open": "Abrir Hydra",
|
"open": "Abrir Hydra",
|
||||||
|
@ -195,7 +195,9 @@
|
|||||||
"game_ready_to_install": "{{title}} está pronto para ser instalado",
|
"game_ready_to_install": "{{title}} está pronto para ser instalado",
|
||||||
"repack_list_updated": "Lista de repacks atualizada",
|
"repack_list_updated": "Lista de repacks atualizada",
|
||||||
"repack_count_one": "{{count}} novo repack",
|
"repack_count_one": "{{count}} novo repack",
|
||||||
"repack_count_other": "{{count}} novos repacks"
|
"repack_count_other": "{{count}} novos repacks",
|
||||||
|
"new_update_available": "Versão {{version}} disponível",
|
||||||
|
"restart_to_install_update": "Reinicie o Hydra para instalar a nova versão"
|
||||||
},
|
},
|
||||||
"system_tray": {
|
"system_tray": {
|
||||||
"open": "Abrir Hydra",
|
"open": "Abrir Hydra",
|
||||||
|
@ -197,7 +197,8 @@
|
|||||||
"game_ready_to_install": "{{title}} готова к установке",
|
"game_ready_to_install": "{{title}} готова к установке",
|
||||||
"repack_list_updated": "Список репаков обновлен",
|
"repack_list_updated": "Список репаков обновлен",
|
||||||
"repack_count_one": "{{count}} репак добавлен",
|
"repack_count_one": "{{count}} репак добавлен",
|
||||||
"repack_count_other": "{{count}} репаков добавлено"
|
"repack_count_other": "{{count}} репаков добавлено",
|
||||||
|
"new_update_available": "Доступна версия {{version}}"
|
||||||
},
|
},
|
||||||
"system_tray": {
|
"system_tray": {
|
||||||
"open": "Открыть Hydra",
|
"open": "Открыть Hydra",
|
||||||
|
@ -3,6 +3,7 @@ import { registerEvent } from "../register-event";
|
|||||||
import updater, { UpdateInfo } from "electron-updater";
|
import updater, { UpdateInfo } from "electron-updater";
|
||||||
import { WindowManager } from "@main/services";
|
import { WindowManager } from "@main/services";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
|
import { publishNotificationUpdateReadyToInstall } from "@main/services/notifications";
|
||||||
|
|
||||||
const { autoUpdater } = updater;
|
const { autoUpdater } = updater;
|
||||||
|
|
||||||
@ -20,13 +21,17 @@ const mockValuesForDebug = () => {
|
|||||||
sendEvent({ type: "update-downloaded" });
|
sendEvent({ type: "update-downloaded" });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const newVersionInfo = { version: "" };
|
||||||
|
|
||||||
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
|
||||||
autoUpdater
|
autoUpdater
|
||||||
.once("update-available", (info: UpdateInfo) => {
|
.once("update-available", (info: UpdateInfo) => {
|
||||||
sendEvent({ type: "update-available", info });
|
sendEvent({ type: "update-available", info });
|
||||||
|
newVersionInfo.version = info.version;
|
||||||
})
|
})
|
||||||
.once("update-downloaded", () => {
|
.once("update-downloaded", () => {
|
||||||
sendEvent({ type: "update-downloaded" });
|
sendEvent({ type: "update-downloaded" });
|
||||||
|
publishNotificationUpdateReadyToInstall(newVersionInfo.version);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
import { registerEvent } from "../register-event";
|
import { registerEvent } from "../register-event";
|
||||||
import AutoLaunch from "auto-launch";
|
import AutoLaunch from "auto-launch";
|
||||||
import { app } from "electron";
|
import { app } from "electron";
|
||||||
|
import path from "path";
|
||||||
|
import fs from "node:fs";
|
||||||
|
import { logger } from "@main/services";
|
||||||
|
|
||||||
|
const windowsStartupPath = path.join(
|
||||||
|
app.getPath("appData"),
|
||||||
|
"Microsoft",
|
||||||
|
"Windows",
|
||||||
|
"Start Menu",
|
||||||
|
"Programs",
|
||||||
|
"Startup"
|
||||||
|
);
|
||||||
|
|
||||||
const autoLaunch = async (
|
const autoLaunch = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
@ -13,9 +25,17 @@ const autoLaunch = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
appLauncher.enable().catch(() => {});
|
appLauncher.enable().catch((err) => {
|
||||||
|
logger.error(err);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
appLauncher.disable().catch(() => {});
|
if (process.platform == "win32") {
|
||||||
|
fs.rm(path.join(windowsStartupPath, "Hydra.vbs"), () => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
appLauncher.disable().catch((err) => {
|
||||||
|
logger.error(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Notification, nativeImage } from "electron";
|
import { Notification, nativeImage } from "electron";
|
||||||
import { t } from "i18next";
|
import { t } from "i18next";
|
||||||
import { parseICO } from "icojs";
|
import { parseICO } from "icojs";
|
||||||
|
import trayIcon from "@resources/tray-icon.png?asset";
|
||||||
import { Game } from "@main/entity";
|
import { Game } from "@main/entity";
|
||||||
import { gameRepository, userPreferencesRepository } from "@main/repository";
|
import { gameRepository, userPreferencesRepository } from "@main/repository";
|
||||||
|
|
||||||
@ -39,11 +39,9 @@ export const publishDownloadCompleteNotification = async (game: Game) => {
|
|||||||
new Notification({
|
new Notification({
|
||||||
title: t("download_complete", {
|
title: t("download_complete", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences.language,
|
|
||||||
}),
|
}),
|
||||||
body: t("game_ready_to_install", {
|
body: t("game_ready_to_install", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences.language,
|
|
||||||
title: game.title,
|
title: game.title,
|
||||||
}),
|
}),
|
||||||
icon,
|
icon,
|
||||||
@ -60,13 +58,26 @@ export const publishNewRepacksNotifications = async (count: number) => {
|
|||||||
new Notification({
|
new Notification({
|
||||||
title: t("repack_list_updated", {
|
title: t("repack_list_updated", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences?.language || "en",
|
|
||||||
}),
|
}),
|
||||||
body: t("repack_count", {
|
body: t("repack_count", {
|
||||||
ns: "notifications",
|
ns: "notifications",
|
||||||
lng: userPreferences?.language || "en",
|
|
||||||
count: count,
|
count: count,
|
||||||
}),
|
}),
|
||||||
}).show();
|
}).show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const publishNotificationUpdateReadyToInstall = async (
|
||||||
|
version: string
|
||||||
|
) => {
|
||||||
|
new Notification({
|
||||||
|
title: t("new_update_available", {
|
||||||
|
ns: "notifications",
|
||||||
|
version,
|
||||||
|
}),
|
||||||
|
body: t("restart_to_install_update", {
|
||||||
|
ns: "notifications",
|
||||||
|
}),
|
||||||
|
icon: trayIcon,
|
||||||
|
}).show();
|
||||||
|
};
|
||||||
|
@ -47,10 +47,8 @@ export function AutoUpdateSubHeader() {
|
|||||||
return (
|
return (
|
||||||
<header className={styles.subheader}>
|
<header className={styles.subheader}>
|
||||||
<Link to={releasesPageUrl} className={styles.newVersionLink}>
|
<Link to={releasesPageUrl} className={styles.newVersionLink}>
|
||||||
<SyncIcon size={12} />
|
<SyncIcon className={styles.newVersionIcon} size={12} />
|
||||||
<small>
|
|
||||||
{t("version_available_download", { version: newVersion })}
|
{t("version_available_download", { version: newVersion })}
|
||||||
</small>
|
|
||||||
</Link>
|
</Link>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
@ -64,10 +62,8 @@ export function AutoUpdateSubHeader() {
|
|||||||
className={styles.newVersionButton}
|
className={styles.newVersionButton}
|
||||||
onClick={handleClickInstallUpdate}
|
onClick={handleClickInstallUpdate}
|
||||||
>
|
>
|
||||||
<SyncIcon size={12} />
|
<SyncIcon className={styles.newVersionIcon} size={12} />
|
||||||
<small>
|
|
||||||
{t("version_available_install", { version: newVersion })}
|
{t("version_available_install", { version: newVersion })}
|
||||||
</small>
|
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
|
@ -157,7 +157,7 @@ export const newVersionButton = style({
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
color: vars.color.body,
|
color: vars.color.body,
|
||||||
fontSize: "13px",
|
fontSize: "12px",
|
||||||
":hover": {
|
":hover": {
|
||||||
textDecoration: "underline",
|
textDecoration: "underline",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
@ -169,5 +169,9 @@ export const newVersionLink = style({
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
color: "#8e919b",
|
color: "#8e919b",
|
||||||
fontSize: "13px",
|
fontSize: "12px",
|
||||||
|
});
|
||||||
|
|
||||||
|
export const newVersionIcon = style({
|
||||||
|
color: vars.color.success,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user