Skip to content

Commit

Permalink
[bugfix] remove auto update for linux builds
Browse files Browse the repository at this point in the history
  • Loading branch information
silentrald committed Dec 10, 2024
1 parent 17e9699 commit 7a35cd2
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const installExtensions = async () => {
.catch(log.error);
};

const createWindow = async (window: AppWindow = "launcher.html") => {
const createWindow = async (window: AppWindow) => {
if (isDebug) {
await installExtensions();
}
Expand Down Expand Up @@ -131,7 +131,9 @@ if (!gotTheLock) {
} else if (associatedFile) {
FileAssociationService.getInstance().handleFileAssociation(associatedFile);
} else {
createWindow();
createWindow(process.platform === "linux"
? "index.html" : "launcher.html"
);
}

SteamLauncherService.getInstance().restoreSteamVR();
Expand Down
14 changes: 10 additions & 4 deletions src/main/services/auto-updater.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ export class AutoUpdaterService {
autoUpdater.autoDownload = false;
}

public isUpdateAvailable(): Promise<boolean> {
return autoUpdater.checkForUpdates().then(info => {
return !!info?.updateInfo && gt(info.updateInfo.version, autoUpdater.currentVersion.version);
}).catch(() => false);
public async isUpdateAvailable(): Promise<boolean> {
return autoUpdater.checkForUpdates()
.then(info => {
return !!info?.updateInfo && gt(
info.updateInfo.version, autoUpdater.currentVersion.version
)})
.catch(error => {
log.error("Could not get update", error);
return false;
});
}

public downloadUpdate(): Observable<Progression> {
Expand Down
60 changes: 46 additions & 14 deletions src/renderer/components/title-bar/title-bar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,51 @@ import { useService } from "renderer/hooks/use-service.hook";
import { lastValueFrom } from "rxjs";
import { useWindowControls } from "renderer/hooks/use-window-controls.hook";

function TitleBarTags({
ipcService
}: Readonly<{
ipcService: IpcService
}>) {
const [previewVersion, setPreviewVersion] = useState("");
const [outdated, setOutdated] = useState(false);

useEffect(() => {
const requests: Promise<any>[] = [
lastValueFrom(ipcService.sendV2("current-version"))
];
if (window.electron.platform === "linux") {
requests.push(lastValueFrom(ipcService.sendV2("check-update")));
}

Promise.all(requests).then(([ currentVersion, outdated ]) => {
handlePrerelease(currentVersion);
setOutdated(outdated);
});
}, []);

const handlePrerelease = (version: string) => {
if (version.toLowerCase().includes("alpha")) {
return setPreviewVersion("ALPHA");
}
if (version.toLowerCase().includes("beta")) {
return setPreviewVersion("BETA");
}
}

return <>
{previewVersion &&
<span className="bg-main-color-1 text-white dark:text-black dark:bg-white rounded-full ml-1 text-[10px] italic px-1 uppercase h-3.5 font-bold">
{previewVersion}
</span>
}
{outdated &&
<span className="bg-main-color-1 text-white dark:text-black dark:bg-white rounded-full ml-1 text-[10px] italic px-1 uppercase h-3.5 font-bold">
Outdated
</span>
}
</>;
}

export default function TitleBar({ template = "index.html" }: { template: AppWindow }) {
const ipcService = useService(IpcService);
const audio = useService(AudioPlayerService);
Expand All @@ -20,19 +65,6 @@ export default function TitleBar({ template = "index.html" }: { template: AppWin
const volume = useObservable(() => audio.volume$, audio.volume);
const color = useThemeColor("first-color");

const [previewVersion, setPreviewVersion] = useState(null);

useEffect(() => {
lastValueFrom(ipcService.sendV2("current-version")).then(version => {
if (version.toLowerCase().includes("alpha")) {
return setPreviewVersion("ALPHA");
}
if (version.toLowerCase().includes("beta")) {
return setPreviewVersion("BETA");
}
});
}, []);

const [maximized, setMaximized] = useState(false);

const closeWindow = () => {
Expand Down Expand Up @@ -76,7 +108,7 @@ export default function TitleBar({ template = "index.html" }: { template: AppWin
<div id="drag-region" className="grow basis-0 h-full">
<div id="window-title" className="pl-1">
<span className="text-gray-800 dark:text-gray-100 font-bold text-xs italic">BSManager</span>
{previewVersion && <span className="bg-main-color-1 text-white dark:text-black dark:bg-white rounded-full ml-1 text-[10px] italic px-1 uppercase h-3.5 font-bold">{previewVersion}</span>}
<TitleBarTags ipcService={ipcService} />
</div>
</div>
<div id="window-controls" className="h-full flex shrink-0 items-center">
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/services/auto-updater.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AutoUpdaterService {
this.ipcService = IpcService.getInstance();
}

public isUpdateAvailable(): Promise<boolean> {
public async isUpdateAvailable(): Promise<boolean> {
return lastValueFrom(this.ipcService.sendV2("check-update")).catch(() => false);
}

Expand Down

0 comments on commit 7a35cd2

Please sign in to comment.