-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from hydralauncher/feat/macos-test
feat: adjust auto update and tray icon for macos
- Loading branch information
Showing
14 changed files
with
155 additions
and
81 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/renderer/src/components/header/auto-update-sub-header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { useEffect, useState } from "react"; | ||
import { SyncIcon } from "@primer/octicons-react"; | ||
import { Link } from "../link/link"; | ||
import * as styles from "./header.css"; | ||
import { AppUpdaterEvent } from "@types"; | ||
|
||
export const releasesPageUrl = | ||
"https://github.com/hydralauncher/hydra/releases/latest"; | ||
|
||
const isMac = window.electron.platform === "darwin"; | ||
|
||
export function AutoUpdateSubHeader() { | ||
const [showUpdateSubheader, setShowUpdateSubheader] = useState(false); | ||
const [newVersion, setNewVersion] = useState(""); | ||
|
||
const { t } = useTranslation("header"); | ||
|
||
const handleClickInstallUpdate = () => { | ||
window.electron.restartAndInstallUpdate(); | ||
}; | ||
|
||
useEffect(() => { | ||
const unsubscribe = window.electron.onAutoUpdaterEvent( | ||
(event: AppUpdaterEvent) => { | ||
if (event.type == "update-available") { | ||
setNewVersion(event.info.version); | ||
|
||
if (isMac) { | ||
setShowUpdateSubheader(true); | ||
} | ||
} | ||
|
||
if (event.type == "update-downloaded") { | ||
setShowUpdateSubheader(true); | ||
} | ||
} | ||
); | ||
|
||
window.electron.checkForUpdates(); | ||
|
||
return () => { | ||
unsubscribe(); | ||
}; | ||
}, []); | ||
|
||
if (!showUpdateSubheader) return null; | ||
|
||
return ( | ||
<header className={styles.subheader}> | ||
{isMac ? ( | ||
<Link to={releasesPageUrl} className={styles.newVersionLink}> | ||
<SyncIcon size={12} /> | ||
<small> | ||
{t("version_available_download", { version: newVersion })} | ||
</small> | ||
</Link> | ||
) : ( | ||
<button | ||
type="button" | ||
className={styles.newVersionButton} | ||
onClick={handleClickInstallUpdate} | ||
> | ||
<SyncIcon size={12} /> | ||
<small> | ||
{t("version_available_install", { version: newVersion })} | ||
</small> | ||
</button> | ||
)} | ||
</header> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.