Skip to content

Commit 1cbb46d

Browse files
Feature/modify menu fix some sonar issues and debug log cookie expiration info (#1449)
* modifying the menu to include zoom, and help sections. Fix some sonarcloud detected issues and add debug log for cookie change for authtoken and domain teams.microsoft.com * fixes on the activityManager and updating dependencies * updating release date * removing the unnecessary Menus argument from getPreferencesMenu
1 parent c94791d commit 1cbb46d

12 files changed

+298
-348
lines changed

app/browser/notifications/activityManager.js

+23-24
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,34 @@ class ActivityManager {
2121
self.ipcRenderer.invoke('get-system-idle-state').then((state) => {
2222
let timeOut;
2323
if (this.config.awayOnSystemIdle) {
24-
/*
25-
Same logic as before:
26-
awayOnSystemIdle = true, sets status "Away" when screen is locked.
27-
*/
28-
activityHub.setMachineState(state.system === 'active' ? 1 : 2);
29-
timeOut = (state.system === 'active' ? self.config.appIdleTimeoutCheckInterval : self.config.appActiveCheckInterval) * 1000;
30-
31-
if (state.system === 'active' && state.userIdle === 1) {
32-
activityHub.setUserStatus(1);
33-
} else if (state.system !== 'active' && state.userCurrent === 1) {
34-
activityHub.setUserStatus(3);
35-
}
24+
timeOut = this.setStatusAwayWhenScreenLocked(state);
3625
} else {
37-
/*
38-
Handle screen locked:
39-
awayOnSystemIdle = false, keeps status "Available" when locking the screen.
40-
*/
41-
if ((state.system === 'active') || (state.system === 'locked')) {
42-
activityHub.setMachineState(1);
43-
timeOut = self.config.appIdleTimeoutCheckInterval * 1000;
44-
} else {
45-
activityHub.setMachineState(2);
46-
timeOut = self.config.appActiveCheckInterval * 1000;
47-
}
26+
timeOut = this.keepStatusAvailableWhenScreenLocked(state);
4827
}
49-
5028
setTimeout(() => self.watchSystemIdleState(), timeOut);
5129
});
5230
}
31+
32+
setStatusAwayWhenScreenLocked(state) {
33+
activityHub.setMachineState(state.system === 'active' ? 1 : 2);
34+
const timeOut = (state.system === 'active' ? this.config.appIdleTimeoutCheckInterval : this.config.appActiveCheckInterval) * 1000;
35+
36+
if (state.system === 'active' && state.userIdle === 1) {
37+
activityHub.setUserStatus(1);
38+
} else if (state.system !== 'active' && state.userCurrent === 1) {
39+
activityHub.setUserStatus(3);
40+
}
41+
return timeOut;
42+
}
43+
44+
keepStatusAvailableWhenScreenLocked(state) {
45+
if ((state.system === 'active') || (state.system === 'locked')) {
46+
activityHub.setMachineState(1);
47+
return this.config.appIdleTimeoutCheckInterval * 1000;
48+
}
49+
activityHub.setMachineState(2);
50+
return this.config.appActiveCheckInterval * 1000;
51+
}
5352
}
5453

5554
function setActivityHandlers(self) {

app/config/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function argv(configPath, appVersion) {
402402

403403
logger.init(config.logConfig);
404404

405-
console.debug('configPath:', configPath);
405+
console.info('configPath:', configPath);
406406
console.debug('configFile:', configObject.configFile);
407407

408408
return config;

app/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function handleCertificateError() {
322322
}
323323

324324
async function requestMediaAccess() {
325-
['camera', 'microphone', 'screen'].map(async (permission) => {
325+
['camera', 'microphone', 'screen'].forEach(async (permission) => {
326326
const status = await
327327
systemPreferences.askForMediaAccess(permission)
328328
.catch(err => {

app/mainAppWindow/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ function onDidFinishLoad() {
160160
`);
161161
customCSS.onDidFinishLoad(window.webContents, config);
162162
initSystemThemeFollow(config);
163+
window.webContents.session.cookies.on('changed', (_event, cookie, cause, removed) => {
164+
if ((cookie.name === 'authtoken') && (cookie.domain === 'teams.microsoft.com')) {
165+
console.debug(`cookie changed cause: ${cause} \n removed?: ${removed} \n`);
166+
console.debug(`cookie: ${cookie.name} \n expirationDate: ${cookie.expirationDate} \n domain: ${cookie.domain}`);
167+
}
168+
});
163169
}
164170

165171
function initSystemThemeFollow(config) {

app/menus/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ To access the main menu, press the 'Alt' key while the application is selected.
66

77
[index.js](index.js) is the entry point. That loads the different files in this folder that define each menu and submenu items.
88

9-
* Application: The [application.js](application.js) file contains the submenu for the application tab. This submenu definition is also in use for the tray menu.
10-
* Help: The help menu is defined in the [help.js](help.js) file.
11-
* Preferences: The preferences submenu gets defined in the [preferences.js](preferences.js) file.
9+
* Application Menu: The [appMenu.js](appMenu.js) file contains the submenu for the application tab. This submenu definition is also in use for the tray menu.
1210
* Tray: [tray.js](tray.js) contains the tray menu and its implementation.

app/menus/application.js renamed to app/menus/appMenu.js

+44-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
const { shell } = require('electron');
2+
13
exports = module.exports = (Menus) => ({
2-
label: 'Application',
4+
label: 'Teams for Linux',
35
submenu: [
46
{
57
label: 'Open',
@@ -25,10 +27,19 @@ exports = module.exports = (Menus) => ({
2527
type: 'separator',
2628
},
2729
getSettingsMenu(Menus),
30+
getPreferencesMenu(),
2831
getNotificationsMenu(Menus),
2932
{
3033
type: 'separator',
3134
},
35+
{
36+
label: 'About',
37+
click: () => Menus.about(),
38+
},
39+
getHelpMenu(),
40+
{
41+
type: 'separator',
42+
},
3243
{
3344
label: 'Quit',
3445
accelerator: 'ctrl+Q',
@@ -38,13 +49,6 @@ exports = module.exports = (Menus) => ({
3849
label: 'Quit (Clear Storage)',
3950
click: () => Menus.quit(true)
4051
},
41-
{
42-
type: 'separator',
43-
},
44-
{
45-
label: 'About',
46-
click: () => Menus.about(),
47-
}
4852
],
4953
});
5054

@@ -64,6 +68,18 @@ function getSettingsMenu(Menus) {
6468
};
6569
}
6670

71+
function getPreferencesMenu() {
72+
return {
73+
label: 'Zoom',
74+
submenu: [
75+
{role: 'resetZoom'},
76+
{role: 'zoomIn'},
77+
{role: 'zoomOut'},
78+
{role: 'togglefullscreen'},
79+
],
80+
}
81+
}
82+
6783
function getNotificationsMenu(Menus) {
6884
return {
6985
label: 'Notifications',
@@ -124,3 +140,23 @@ function getNotificationsMenu(Menus) {
124140
]
125141
};
126142
}
143+
144+
function getHelpMenu () {
145+
return {
146+
label: 'Help',
147+
submenu: [
148+
{
149+
label: 'Online Documentation',
150+
click: () => shell.openExternal('https://support.office.com/en-us/teams'),
151+
},
152+
{
153+
label: 'Github Project',
154+
click: () => shell.openExternal('https://github.com/IsmaelMartinez/teams-for-linux'),
155+
},
156+
{
157+
label: 'Microsoft Teams Support',
158+
click:() => shell.openExternal('https://answers.microsoft.com/en-us/msteams/forum'),
159+
},
160+
],
161+
};
162+
}

app/menus/help.js

-25
This file was deleted.

app/menus/index.js

+7-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
const { app, Menu, MenuItem, clipboard, dialog, session, ipcMain } = require('electron');
22
const fs = require('fs'),
33
path = require('path');
4-
const application = require('./application');
5-
const preferences = require('./preferences');
6-
const help = require('./help');
4+
const appMenu = require('./appMenu');
75
const Tray = require('./tray');
86
const { SpellCheckProvider } = require('../spellCheckProvider');
97
const connectionManager = require('../connectionManager');
@@ -93,21 +91,17 @@ class Menus {
9391
}
9492

9593
initialize() {
96-
const appMenu = application(this);
94+
const menu = appMenu(this);
9795

9896
if (this.configGroup.startupConfig.menubar == 'hidden') {
9997
this.window.removeMenu();
10098
} else {
101-
this.window.setMenu(Menu.buildFromTemplate([
102-
appMenu,
103-
preferences(),
104-
help(app, this.window),
105-
]));
99+
this.window.setMenu(Menu.buildFromTemplate([menu]));
106100
}
107101

108102
this.initializeEventHandlers();
109103

110-
this.tray = new Tray(this.window, appMenu.submenu, this.iconPath, this.configGroup.startupConfig);
104+
this.tray = new Tray(this.window, menu.submenu, this.iconPath, this.configGroup.startupConfig);
111105
this.spellCheckProvider = new SpellCheckProvider(this.window);
112106
}
113107

@@ -144,13 +138,9 @@ class Menus {
144138
}
145139

146140
updateMenu() {
147-
const appMenu = application(this);
148-
this.window.setMenu(Menu.buildFromTemplate([
149-
appMenu,
150-
preferences(),
151-
help(app, this.window),
152-
]));
153-
this.tray.setContextMenu(appMenu.submenu);
141+
const menu = appMenu(this);
142+
this.window.setMenu(Menu.buildFromTemplate([menu]));
143+
this.tray.setContextMenu(menu.submenu);
154144
}
155145

156146
toggleDisableNotifications() {

app/menus/preferences.js

-14
This file was deleted.

com.github.IsmaelMartinez.teams_for_linux.appdata.xml

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
<url type="bugtracker">https://github.com/IsmaelMartinez/teams-for-linux/issues</url>
1515
<launchable type="desktop-id">com.github.IsmaelMartinez.teams_for_linux.desktop</launchable>
1616
<releases>
17+
<release version="1.11.2" date="2024-10-16">
18+
<description>
19+
<ul>
20+
<li>Modifying the menu to include zoom, and help sections</li>
21+
<li>Fix some sonarcloud detected issues</li>
22+
<li>Add debug log for cookie change for authtoken and domain teams.microsoft.com</li>
23+
<li>Updated electron to 32.2.0</li>
24+
<li>Updated electron-builder 25.1.8</li>
25+
</ul>
26+
</description>
27+
</release>
1728
<release version="1.11.1" date="2024-10-03">
1829
<description>
1930
<ul>

0 commit comments

Comments
 (0)