Skip to content

Commit

Permalink
connectionLabel
Browse files Browse the repository at this point in the history
0.23.9-beta
  • Loading branch information
ircfspace committed Jun 11, 2024
1 parent ce426f3 commit 5822262
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://github.com/bepass-org/oblivion-desktop/issues",
"email": "[email protected]"
},
"version": "0.23.7-beta",
"version": "0.23.9-beta",
"license": "Restrictive",
"main": "./src/main/main.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oblivion-desktop",
"description": "unofficial desktop version of oblivion",
"version": "0.23.7-beta",
"version": "0.23.9-beta",
"homepage": "https://github.com/bepass-org/oblivion-desktop#readme",
"license": "Restrictive",
"author": "ircfspace+kiomarzsss <[email protected]> (https://ircf.space/)",
Expand Down
38 changes: 21 additions & 17 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ if (!gotTheLock) {
type: 'normal',
enabled: connectEnable,
click: () => {
if ( connectStatus === 'disconnected' ) {
trayMenuEvent?.reply('tray-menu', {
key: 'connectToggle',
msg: 'Connect Tray Click!'
});
if (connectStatus === 'disconnected') {
trayMenuEvent?.reply('tray-menu', {
key: 'connectToggle',
msg: 'Connect Tray Click!'
});
}
/*appIcon.setContextMenu(
Menu.buildFromTemplate(
Expand Down Expand Up @@ -375,14 +375,28 @@ if (!gotTheLock) {
];
};

const connectionLabel = (status: string) => {
let text = '';
if (status.startsWith('connected')) {
text = `✓ ${appLang.systemTray.connected}`;
} else if (status === 'disconnected') {
text = appLang.systemTray.connect;
} else if (status === 'connecting') {
text = appLang.systemTray.connecting;
} else if (status === 'disconnecting') {
text = appLang.systemTray.disconnecting;
}
return text;
};

const systemTrayMenu = (status: string) => {
appIcon = new Tray(trayIconChanger(status));
appIcon.on('click', async () => {
redirectTo('');
});
appIcon.setToolTip(appTitle);
appIcon.setContextMenu(
Menu.buildFromTemplate(trayMenuContext(appLang.systemTray.connect, status, true))
Menu.buildFromTemplate(trayMenuContext(connectionLabel(status), status, true))
);
};

Expand All @@ -396,20 +410,10 @@ if (!gotTheLock) {
if (newStatus.startsWith('connected') || newStatus === 'disconnected') {
appIcon.setImage(trayIconChanger(newStatus));
}
let connectionStatus = '';
if (newStatus.startsWith('connected')) {
connectionStatus = `✓ ${appLang.systemTray.connected}`;
} else if (newStatus === 'disconnected') {
connectionStatus = appLang.systemTray.connect;
} else if (newStatus === 'connecting') {
connectionStatus = appLang.systemTray.connecting;
} else if (newStatus === 'disconnecting') {
connectionStatus = appLang.systemTray.disconnecting;
}
appIcon.setContextMenu(
Menu.buildFromTemplate(
trayMenuContext(
connectionStatus,
connectionLabel(newStatus),
newStatus,
!(newStatus === 'disconnecting' || newStatus === 'connecting')
)
Expand Down

0 comments on commit 5822262

Please sign in to comment.