Compare commits
9 commits
main
...
tray-stuff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dccaf6274e | ||
|
|
03006efd08 | ||
|
|
0974da2532 | ||
|
|
b8a9181c32 | ||
|
|
bc87f72421 | ||
|
|
cd5e142116 | ||
|
|
a43d15deb3 | ||
|
|
3f0263575c | ||
|
|
8990f7a44d |
6 changed files with 14 additions and 65 deletions
|
|
@ -135,9 +135,4 @@ window.VencordNative = {
|
||||||
|
|
||||||
pluginHelpers: {} as any,
|
pluginHelpers: {} as any,
|
||||||
csp: {} as any,
|
csp: {} as any,
|
||||||
tray: {
|
|
||||||
setUpdateState: NOOP,
|
|
||||||
onCheckUpdates: NOOP,
|
|
||||||
onRepair: NOOP,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ import { StartAt } from "@utils/types";
|
||||||
import { SettingsRouter } from "@webpack/common";
|
import { SettingsRouter } from "@webpack/common";
|
||||||
|
|
||||||
import { get as dsGet } from "./api/DataStore";
|
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 { NotificationData, showNotification } from "./api/Notifications";
|
||||||
import { initPluginManager, PMLogger, startAllPlugins } from "./api/PluginManager";
|
import { initPluginManager, PMLogger, startAllPlugins } from "./api/PluginManager";
|
||||||
import { PlainSettings, Settings, SettingsStore } from "./api/Settings";
|
import { PlainSettings, Settings, SettingsStore } from "./api/Settings";
|
||||||
import { areLocalSettingsDirty, getCloudSettings, getCloudSyncDirection, markLocalSettingsDirty, putCloudSettings, shouldCloudSync } from "./api/SettingsSync/cloudSync";
|
import { areLocalSettingsDirty, getCloudSettings, getCloudSyncDirection, markLocalSettingsDirty, putCloudSettings, shouldCloudSync } from "./api/SettingsSync/cloudSync";
|
||||||
import { relaunch } from "./utils/native";
|
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 { onceReady } from "./webpack";
|
||||||
import { patches } from "./webpack/patchWebpack";
|
import { patches } from "./webpack/patchWebpack";
|
||||||
|
|
||||||
|
|
@ -135,7 +135,6 @@ async function runUpdateCheck() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isOutdated = await checkForUpdates();
|
const isOutdated = await checkForUpdates();
|
||||||
if (IS_DISCORD_DESKTOP) VencordNative.tray.setUpdateState(isOutdated);
|
|
||||||
if (!isOutdated) return;
|
if (!isOutdated) return;
|
||||||
|
|
||||||
if (Settings.autoUpdate) {
|
if (Settings.autoUpdate) {
|
||||||
|
|
@ -166,43 +165,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() {
|
async function init() {
|
||||||
await onceReady;
|
await onceReady;
|
||||||
startAllPlugins(StartAt.WebpackReady);
|
startAllPlugins(StartAt.WebpackReady);
|
||||||
|
|
||||||
syncSettings();
|
syncSettings();
|
||||||
initTrayIpc();
|
|
||||||
|
|
||||||
if (!IS_DEV && !IS_WEB && !IS_UPDATER_DISABLED) {
|
if (!IS_DEV && !IS_WEB && !IS_UPDATER_DISABLED) {
|
||||||
runUpdateCheck();
|
runUpdateCheck();
|
||||||
|
|
|
||||||
|
|
@ -98,11 +98,5 @@ export default {
|
||||||
invoke<CspRequestResult>(IpcEvents.CSP_REQUEST_ADD_OVERRIDE, url, directives, callerName),
|
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); },
|
|
||||||
},
|
|
||||||
|
|
||||||
pluginHelpers: PluginHelpers
|
pluginHelpers: PluginHelpers
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,11 @@
|
||||||
|
|
||||||
import { IpcEvents } from "@shared/IpcEvents";
|
import { IpcEvents } from "@shared/IpcEvents";
|
||||||
import { gitHashShort } from "@shared/vencordUserAgent";
|
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 aboutHtml from "file://about.html?minify";
|
||||||
|
|
||||||
import { SETTINGS_DIR, THEMES_DIR } from "./utils/constants";
|
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 {
|
function getMainWindow(): BrowserWindow | undefined {
|
||||||
return BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0];
|
return BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0];
|
||||||
}
|
}
|
||||||
|
|
@ -101,12 +95,16 @@ function createEquicordMenuItems(): MenuItemConstructorOptions[] {
|
||||||
click: () => openAboutWindow()
|
click: () => openAboutWindow()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: cachedUpdateAvailable ? "Update Equicord" : "Check for Updates",
|
label: "Update Equicord",
|
||||||
click: () => sendToRenderer(IpcEvents.TRAY_CHECK_UPDATES)
|
click: async () => {
|
||||||
},
|
try {
|
||||||
{
|
sendToRenderer(IpcEvents.GET_UPDATES);
|
||||||
label: "Repair Equicord",
|
sendToRenderer(IpcEvents.UPDATE);
|
||||||
click: () => sendToRenderer(IpcEvents.TRAY_REPAIR)
|
sendToRenderer(IpcEvents.BUILD);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Failed to check updates from tray", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ type: "separator" },
|
{ type: "separator" },
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,4 @@ export const enum IpcEvents {
|
||||||
GET_RENDERER_CSS = "VencordGetRendererCss",
|
GET_RENDERER_CSS = "VencordGetRendererCss",
|
||||||
RENDERER_CSS_UPDATE = "VencordRendererCssUpdate",
|
RENDERER_CSS_UPDATE = "VencordRendererCssUpdate",
|
||||||
PRELOAD_GET_RENDERER_JS = "VencordPreloadGetRendererJs",
|
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