mirror of
				https://github.com/hydralauncher/hydra.git
				synced 2025-03-09 15:40:26 +00:00 
			
		
		
		
	Merge branch 'main' into feature/adding-animation-to-game-details
This commit is contained in:
		
						commit
						5cd497d0c9
					
				
					 3 changed files with 30 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -12,6 +12,9 @@ const sendEvent = (event: AppUpdaterEvent) => {
 | 
			
		|||
 | 
			
		||||
const sendEventsForDebug = false;
 | 
			
		||||
 | 
			
		||||
const isAutoInstallAvailable =
 | 
			
		||||
  process.platform !== "darwin" && process.env.PORTABLE_EXECUTABLE_FILE == null;
 | 
			
		||||
 | 
			
		||||
const mockValuesForDebug = () => {
 | 
			
		||||
  sendEvent({ type: "update-available", info: { version: "1.3.0" } });
 | 
			
		||||
  sendEvent({ type: "update-downloaded" });
 | 
			
		||||
| 
						 | 
				
			
			@ -27,10 +30,13 @@ const checkForUpdates = async (_event: Electron.IpcMainInvokeEvent) => {
 | 
			
		|||
    });
 | 
			
		||||
 | 
			
		||||
  if (app.isPackaged) {
 | 
			
		||||
    autoUpdater.autoDownload = isAutoInstallAvailable;
 | 
			
		||||
    autoUpdater.checkForUpdates();
 | 
			
		||||
  } else if (sendEventsForDebug) {
 | 
			
		||||
    mockValuesForDebug();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return isAutoInstallAvailable;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
registerEvent("checkForUpdates", checkForUpdates);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,11 +8,10 @@ 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 [isReadyToInstall, setIsReadyToInstall] = useState(false);
 | 
			
		||||
  const [newVersion, setNewVersion] = useState<string | null>(null);
 | 
			
		||||
  const [isAutoInstallAvailable, setIsAutoInstallAvailable] = useState(false);
 | 
			
		||||
 | 
			
		||||
  const { t } = useTranslation("header");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -25,37 +24,41 @@ export function AutoUpdateSubHeader() {
 | 
			
		|||
      (event: AppUpdaterEvent) => {
 | 
			
		||||
        if (event.type == "update-available") {
 | 
			
		||||
          setNewVersion(event.info.version);
 | 
			
		||||
 | 
			
		||||
          if (isMac) {
 | 
			
		||||
            setShowUpdateSubheader(true);
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (event.type == "update-downloaded") {
 | 
			
		||||
          setShowUpdateSubheader(true);
 | 
			
		||||
          setIsReadyToInstall(true);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    window.electron.checkForUpdates();
 | 
			
		||||
    window.electron.checkForUpdates().then((isAutoInstallAvailable) => {
 | 
			
		||||
      setIsAutoInstallAvailable(isAutoInstallAvailable);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    return () => {
 | 
			
		||||
      unsubscribe();
 | 
			
		||||
    };
 | 
			
		||||
  }, []);
 | 
			
		||||
 | 
			
		||||
  if (!showUpdateSubheader) return null;
 | 
			
		||||
  if (!newVersion) return null;
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <header className={styles.subheader}>
 | 
			
		||||
      {isMac ? (
 | 
			
		||||
  if (!isAutoInstallAvailable) {
 | 
			
		||||
    return (
 | 
			
		||||
      <header className={styles.subheader}>
 | 
			
		||||
        <Link to={releasesPageUrl} className={styles.newVersionLink}>
 | 
			
		||||
          <SyncIcon size={12} />
 | 
			
		||||
          <small>
 | 
			
		||||
            {t("version_available_download", { version: newVersion })}
 | 
			
		||||
          </small>
 | 
			
		||||
        </Link>
 | 
			
		||||
      ) : (
 | 
			
		||||
      </header>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (isReadyToInstall) {
 | 
			
		||||
    return (
 | 
			
		||||
      <header className={styles.subheader}>
 | 
			
		||||
        <button
 | 
			
		||||
          type="button"
 | 
			
		||||
          className={styles.newVersionButton}
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +69,9 @@ export function AutoUpdateSubHeader() {
 | 
			
		|||
            {t("version_available_install", { version: newVersion })}
 | 
			
		||||
          </small>
 | 
			
		||||
        </button>
 | 
			
		||||
      )}
 | 
			
		||||
    </header>
 | 
			
		||||
  );
 | 
			
		||||
      </header>
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return null;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								src/renderer/src/declaration.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/renderer/src/declaration.d.ts
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -107,7 +107,7 @@ declare global {
 | 
			
		|||
    onAutoUpdaterEvent: (
 | 
			
		||||
      cb: (event: AppUpdaterEvent) => void
 | 
			
		||||
    ) => () => Electron.IpcRenderer;
 | 
			
		||||
    checkForUpdates: () => Promise<void>;
 | 
			
		||||
    checkForUpdates: () => Promise<boolean>;
 | 
			
		||||
    restartAndInstallUpdate: () => Promise<void>;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue