Add basic update notifications (#9)

This commit is contained in:
V
2023-04-10 22:53:44 +02:00
committed by GitHub
parent bfb9af05b0
commit 8d51cd5029
13 changed files with 305 additions and 28 deletions

View File

@@ -8,6 +8,7 @@ import "./ipc";
import { app, BrowserWindow } from "electron";
import { join } from "path";
import { checkUpdates } from "updater/main";
import { ICON_PATH } from "../shared/paths";
import { once } from "../shared/utils/once";
@@ -40,6 +41,7 @@ if (!app.requestSingleInstanceLock()) {
});
app.whenReady().then(async () => {
checkUpdates();
if (process.platform === "win32") app.setAppUserModelId("dev.vencord.desktop");
else if (process.platform === "darwin") app.dock.setIcon(ICON_PATH);

View File

@@ -52,8 +52,12 @@ ipcMain.handle(IpcEvents.SHOW_ITEM_IN_FOLDER, (_, path) => {
shell.showItemInFolder(path);
});
ipcMain.handle(IpcEvents.FOCUS, () => {
mainWin?.focus();
ipcMain.handle(IpcEvents.FOCUS, e => {
e.sender.focus();
});
ipcMain.handle(IpcEvents.CLOSE, e => {
e.sender.close();
});
ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {

View File

@@ -6,18 +6,11 @@
import { BrowserWindow } from "electron";
import { join } from "path";
import { SplashProps } from "shared/browserWinProperties";
import { STATIC_DIR } from "shared/paths";
export function createSplashWindow() {
const splash = new BrowserWindow({
transparent: true,
frame: false,
height: 350,
width: 300,
center: true,
resizable: false,
maximizable: false
});
const splash = new BrowserWindow(SplashProps);
splash.loadFile(join(STATIC_DIR, "splash.html"));

View File

@@ -11,10 +11,20 @@ import { join } from "path";
import { USER_AGENT, VENCORD_FILES_DIR } from "../constants";
import { downloadFile, simpleGet } from "./http";
const API_BASE = "https://api.github.com/repos/Vendicated/Vencord";
const API_BASE = "https://api.github.com";
const FILES_TO_DOWNLOAD = ["vencordDesktopMain.js", "preload.js", "vencordDesktopRenderer.js", "renderer.css"];
export interface ReleaseData {
name: string;
tag_name: string;
html_url: string;
assets: Array<{
name: string;
browser_download_url: string;
}>;
}
export async function githubGet(endpoint: string) {
const opts: RequestOptions = {
headers: {
@@ -29,13 +39,9 @@ export async function githubGet(endpoint: string) {
}
export async function downloadVencordFiles() {
const release = await githubGet("/releases/latest");
const release = await githubGet("/repos/Vendicated/Vencord/releases/latest");
const data = JSON.parse(release.toString("utf-8"));
const assets = data.assets as Array<{
name: string;
browser_download_url: string;
}>;
const { assets } = JSON.parse(release.toString("utf-8")) as ReleaseData;
await Promise.all(
assets