mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Simplify tray's code
This commit is contained in:
parent
dcc28fe381
commit
359f2174b7
1 changed files with 53 additions and 104 deletions
51
src/tray.ts
51
src/tray.ts
|
@ -27,56 +27,6 @@ app.whenReady().then(async () => {
|
|||
if (process.platform == "darwin" && trayPath.getSize().height > 22) trayPath = trayPath.resize({height: 22});
|
||||
if (await getConfig("tray")) {
|
||||
let clientName = (await getConfig("clientName")) ?? "ArmCord";
|
||||
if ((await getConfig("windowStyle")) == "basic") {
|
||||
tray = new Tray(trayPath);
|
||||
function contextMenu(): Electron.Menu {
|
||||
if (finishedSetup == false) {
|
||||
return Menu.buildFromTemplate([
|
||||
{
|
||||
label: `Finish the setup first!`,
|
||||
enabled: false
|
||||
},
|
||||
{
|
||||
label: `Quit ${clientName}`,
|
||||
async click() {
|
||||
fs.unlink(await getConfigLocation(), (err) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('Closed during setup. "settings.json" was deleted');
|
||||
app.quit();
|
||||
});
|
||||
}
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
return Menu.buildFromTemplate([
|
||||
{
|
||||
label: `Open ${clientName}`,
|
||||
click() {
|
||||
mainWindow.show();
|
||||
}
|
||||
},
|
||||
{
|
||||
label: `Quit ${clientName}`,
|
||||
click() {
|
||||
let [width, height] = mainWindow.getSize();
|
||||
setWindowState({
|
||||
width,
|
||||
height,
|
||||
isMaximized: mainWindow.isMaximized(),
|
||||
x: mainWindow.getPosition()[0],
|
||||
y: mainWindow.getPosition()[1]
|
||||
});
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
tray.setToolTip(clientName);
|
||||
tray.setContextMenu(contextMenu);
|
||||
} else {
|
||||
tray = new Tray(trayPath);
|
||||
if (finishedSetup == false) {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
|
@ -137,7 +87,6 @@ app.whenReady().then(async () => {
|
|||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
}
|
||||
}
|
||||
tray.setToolTip(clientName);
|
||||
tray.on("click", function () {
|
||||
mainWindow.show();
|
||||
|
|
Loading…
Reference in a new issue