this is broken
This commit is contained in:
parent
175a5ff2c0
commit
8990f7a44d
6 changed files with 14 additions and 67 deletions
|
|
@ -135,10 +135,4 @@ window.VencordNative = {
|
|||
|
||||
pluginHelpers: {} as any,
|
||||
csp: {} as any,
|
||||
tray: {
|
||||
setUpdateState: NOOP,
|
||||
onCheckUpdates: NOOP,
|
||||
onRepair: NOOP,
|
||||
onAbout: NOOP,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19439,4 +19439,4 @@
|
|||
"FD9mUy": "DESKTOP_DOWNLOAD_TITLE_LINUX",
|
||||
"hmGBzx": "DESKTOP_DOWNLOAD_TITLE_MAC",
|
||||
"GY/qwb": "DESKTOP_DOWNLOAD_TITLE_WINDOWS"
|
||||
}
|
||||
}
|
||||
|
|
@ -37,14 +37,14 @@ import { StartAt } from "@utils/types";
|
|||
import { SettingsRouter } from "@webpack/common";
|
||||
|
||||
import { get as dsGet } from "./api/DataStore";
|
||||
import { popNotice, showNotice } from "./api/Notices";
|
||||
import { showNotice } from "./api/Notices";
|
||||
import { NotificationData, showNotification } from "./api/Notifications";
|
||||
import { initPluginManager, PMLogger, startAllPlugins } from "./api/PluginManager";
|
||||
import { PlainSettings, Settings, SettingsStore } from "./api/Settings";
|
||||
import { getCloudSettings, putCloudSettings, shouldCloudSync } from "./api/SettingsSync/cloudSync";
|
||||
import { localStorage } from "./utils/localStorage";
|
||||
import { relaunch } from "./utils/native";
|
||||
import { checkForUpdates, isOutdated as getIsOutdated, update, UpdateLogger } from "./utils/updater";
|
||||
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
|
||||
import { onceReady } from "./webpack";
|
||||
import { patches } from "./webpack/patchWebpack";
|
||||
|
||||
|
|
@ -141,7 +141,6 @@ async function runUpdateCheck() {
|
|||
|
||||
try {
|
||||
const isOutdated = await checkForUpdates();
|
||||
if (IS_DISCORD_DESKTOP) VencordNative.tray.setUpdateState(isOutdated);
|
||||
if (!isOutdated) return;
|
||||
|
||||
if (Settings.autoUpdate) {
|
||||
|
|
@ -172,43 +171,11 @@ async function runUpdateCheck() {
|
|||
}
|
||||
}
|
||||
|
||||
function initTrayIpc() {
|
||||
if (IS_WEB || IS_UPDATER_DISABLED) return;
|
||||
|
||||
VencordNative.tray.onCheckUpdates(async () => {
|
||||
try {
|
||||
const isOutdated = await checkForUpdates();
|
||||
VencordNative.tray.setUpdateState(isOutdated);
|
||||
|
||||
if (isOutdated) {
|
||||
showNotice("An Equicord update is available!", "View Update", () => openSettingsTabModal(UpdaterTab!));
|
||||
} else {
|
||||
showNotice("No updates available, you're on the latest version!", "OK", popNotice);
|
||||
}
|
||||
} catch (err) {
|
||||
UpdateLogger.error("Failed to check for updates from tray", err);
|
||||
showNotice("Failed to check for updates, check the console for more info", "OK", popNotice);
|
||||
}
|
||||
});
|
||||
|
||||
VencordNative.tray.onRepair(async () => {
|
||||
try {
|
||||
await update();
|
||||
relaunch();
|
||||
} catch (err) {
|
||||
UpdateLogger.error("Failed to repair Equicord", err);
|
||||
}
|
||||
});
|
||||
|
||||
VencordNative.tray.setUpdateState(getIsOutdated);
|
||||
}
|
||||
|
||||
async function init() {
|
||||
await onceReady;
|
||||
startAllPlugins(StartAt.WebpackReady);
|
||||
|
||||
syncSettings();
|
||||
initTrayIpc();
|
||||
|
||||
if (!IS_DEV && !IS_WEB && !IS_UPDATER_DISABLED) {
|
||||
runUpdateCheck();
|
||||
|
|
|
|||
|
|
@ -98,12 +98,5 @@ export default {
|
|||
invoke<CspRequestResult>(IpcEvents.CSP_REQUEST_ADD_OVERRIDE, url, directives, callerName),
|
||||
},
|
||||
|
||||
tray: {
|
||||
setUpdateState: (available: boolean) => ipcRenderer.send(IpcEvents.SET_TRAY_UPDATE_STATE, available),
|
||||
onCheckUpdates: (cb: () => void) => { ipcRenderer.on(IpcEvents.TRAY_CHECK_UPDATES, cb); },
|
||||
onRepair: (cb: () => void) => { ipcRenderer.on(IpcEvents.TRAY_REPAIR, cb); },
|
||||
onAbout: (cb: () => void) => { ipcRenderer.on(IpcEvents.TRAY_ABOUT, cb); },
|
||||
},
|
||||
|
||||
pluginHelpers: PluginHelpers
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,17 +6,11 @@
|
|||
|
||||
import { IpcEvents } from "@shared/IpcEvents";
|
||||
import { gitHashShort } from "@shared/vencordUserAgent";
|
||||
import { BrowserWindow, ipcMain, Menu, MenuItemConstructorOptions, shell } from "electron";
|
||||
import { BrowserWindow, Menu, MenuItemConstructorOptions, shell } from "electron";
|
||||
import aboutHtml from "file://about.html?minify";
|
||||
|
||||
import { SETTINGS_DIR, THEMES_DIR } from "./utils/constants";
|
||||
|
||||
let cachedUpdateAvailable = false;
|
||||
|
||||
ipcMain.on(IpcEvents.SET_TRAY_UPDATE_STATE, (_, available: boolean) => {
|
||||
cachedUpdateAvailable = available;
|
||||
});
|
||||
|
||||
function getMainWindow(): BrowserWindow | undefined {
|
||||
return BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0];
|
||||
}
|
||||
|
|
@ -101,12 +95,16 @@ function createEquicordMenuItems(): MenuItemConstructorOptions[] {
|
|||
click: () => openAboutWindow()
|
||||
},
|
||||
{
|
||||
label: cachedUpdateAvailable ? "Update Equicord" : "Check for Updates",
|
||||
click: () => sendToRenderer(IpcEvents.TRAY_CHECK_UPDATES)
|
||||
},
|
||||
{
|
||||
label: "Repair Equicord",
|
||||
click: () => sendToRenderer(IpcEvents.TRAY_REPAIR)
|
||||
label: "Update Equicord",
|
||||
click: async () => {
|
||||
try {
|
||||
sendToRenderer(IpcEvents.GET_UPDATES);
|
||||
sendToRenderer(IpcEvents.UPDATE);
|
||||
sendToRenderer(IpcEvents.BUILD);
|
||||
} catch (err) {
|
||||
console.error("Failed to check updates from tray", err);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,9 +51,4 @@ export const enum IpcEvents {
|
|||
GET_RENDERER_CSS = "VencordGetRendererCss",
|
||||
RENDERER_CSS_UPDATE = "VencordRendererCssUpdate",
|
||||
PRELOAD_GET_RENDERER_JS = "VencordPreloadGetRendererJs",
|
||||
|
||||
SET_TRAY_UPDATE_STATE = "VencordSetTrayUpdateState",
|
||||
TRAY_REPAIR = "VencordTrayRepair",
|
||||
TRAY_CHECK_UPDATES = "VencordTrayCheckUpdates",
|
||||
TRAY_ABOUT = "VencordTrayAbout"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue