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
157
src/tray.ts
157
src/tray.ts
|
@ -27,116 +27,65 @@ app.whenReady().then(async () => {
|
||||||
if (process.platform == "darwin" && trayPath.getSize().height > 22) trayPath = trayPath.resize({height: 22});
|
if (process.platform == "darwin" && trayPath.getSize().height > 22) trayPath = trayPath.resize({height: 22});
|
||||||
if (await getConfig("tray")) {
|
if (await getConfig("tray")) {
|
||||||
let clientName = (await getConfig("clientName")) ?? "ArmCord";
|
let clientName = (await getConfig("clientName")) ?? "ArmCord";
|
||||||
if ((await getConfig("windowStyle")) == "basic") {
|
tray = new Tray(trayPath);
|
||||||
tray = new Tray(trayPath);
|
if (finishedSetup == false) {
|
||||||
function contextMenu(): Electron.Menu {
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
if (finishedSetup == false) {
|
{
|
||||||
return Menu.buildFromTemplate([
|
label: `Finish the setup first!`,
|
||||||
{
|
enabled: false
|
||||||
label: `Finish the setup first!`,
|
},
|
||||||
enabled: false
|
{
|
||||||
},
|
label: `Quit ${clientName}`,
|
||||||
{
|
async click() {
|
||||||
label: `Quit ${clientName}`,
|
fs.unlink(await getConfigLocation(), (err) => {
|
||||||
async click() {
|
if (err) throw err;
|
||||||
fs.unlink(await getConfigLocation(), (err) => {
|
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
console.log('Closed during setup. "settings.json" was deleted');
|
console.log('Closed during setup. "settings.json" was deleted');
|
||||||
app.quit();
|
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);
|
tray.setContextMenu(contextMenu);
|
||||||
} else {
|
} else {
|
||||||
tray = new Tray(trayPath);
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
if (finishedSetup == false) {
|
{
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
label: `${clientName} ${getDisplayVersion()}`,
|
||||||
{
|
icon: trayVerIcon(),
|
||||||
label: `Finish the setup first!`,
|
enabled: false
|
||||||
enabled: false
|
},
|
||||||
},
|
{
|
||||||
{
|
type: "separator"
|
||||||
label: `Quit ${clientName}`,
|
},
|
||||||
async click() {
|
{
|
||||||
fs.unlink(await getConfigLocation(), (err) => {
|
label: `Open ${clientName}`,
|
||||||
if (err) throw err;
|
click() {
|
||||||
|
mainWindow.show();
|
||||||
console.log('Closed during setup. "settings.json" was deleted');
|
|
||||||
app.quit();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
tray.setContextMenu(contextMenu);
|
{
|
||||||
} else {
|
label: "Open Settings",
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
click() {
|
||||||
{
|
createSettingsWindow();
|
||||||
label: `${clientName} ${getDisplayVersion()}`,
|
|
||||||
icon: trayVerIcon(),
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "separator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: `Open ${clientName}`,
|
|
||||||
click() {
|
|
||||||
mainWindow.show();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Open Settings",
|
|
||||||
click() {
|
|
||||||
createSettingsWindow();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Support Discord Server",
|
|
||||||
click() {
|
|
||||||
createInviteWindow("TnhxcqynZ2");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: "separator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: `Quit ${clientName}`,
|
|
||||||
click() {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]);
|
},
|
||||||
tray.setContextMenu(contextMenu);
|
{
|
||||||
}
|
label: "Support Discord Server",
|
||||||
|
click() {
|
||||||
|
createInviteWindow("TnhxcqynZ2");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "separator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: `Quit ${clientName}`,
|
||||||
|
click() {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
}
|
}
|
||||||
tray.setToolTip(clientName);
|
tray.setToolTip(clientName);
|
||||||
tray.on("click", function () {
|
tray.on("click", function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue