Skip to content

Commit

Permalink
Feature/modify menu fix some sonar issues and debug log cookie expira…
Browse files Browse the repository at this point in the history
…tion 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
  • Loading branch information
IsmaelMartinez authored Oct 16, 2024
1 parent c94791d commit 1cbb46d
Show file tree
Hide file tree
Showing 12 changed files with 298 additions and 348 deletions.
47 changes: 23 additions & 24 deletions app/browser/notifications/activityManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,34 @@ class ActivityManager {
self.ipcRenderer.invoke('get-system-idle-state').then((state) => {
let timeOut;
if (this.config.awayOnSystemIdle) {
/*
Same logic as before:
awayOnSystemIdle = true, sets status "Away" when screen is locked.
*/
activityHub.setMachineState(state.system === 'active' ? 1 : 2);
timeOut = (state.system === 'active' ? self.config.appIdleTimeoutCheckInterval : self.config.appActiveCheckInterval) * 1000;

if (state.system === 'active' && state.userIdle === 1) {
activityHub.setUserStatus(1);
} else if (state.system !== 'active' && state.userCurrent === 1) {
activityHub.setUserStatus(3);
}
timeOut = this.setStatusAwayWhenScreenLocked(state);
} else {
/*
Handle screen locked:
awayOnSystemIdle = false, keeps status "Available" when locking the screen.
*/
if ((state.system === 'active') || (state.system === 'locked')) {
activityHub.setMachineState(1);
timeOut = self.config.appIdleTimeoutCheckInterval * 1000;
} else {
activityHub.setMachineState(2);
timeOut = self.config.appActiveCheckInterval * 1000;
}
timeOut = this.keepStatusAvailableWhenScreenLocked(state);
}

setTimeout(() => self.watchSystemIdleState(), timeOut);
});
}

setStatusAwayWhenScreenLocked(state) {
activityHub.setMachineState(state.system === 'active' ? 1 : 2);
const timeOut = (state.system === 'active' ? this.config.appIdleTimeoutCheckInterval : this.config.appActiveCheckInterval) * 1000;

if (state.system === 'active' && state.userIdle === 1) {
activityHub.setUserStatus(1);
} else if (state.system !== 'active' && state.userCurrent === 1) {
activityHub.setUserStatus(3);
}
return timeOut;
}

keepStatusAvailableWhenScreenLocked(state) {
if ((state.system === 'active') || (state.system === 'locked')) {
activityHub.setMachineState(1);
return this.config.appIdleTimeoutCheckInterval * 1000;
}
activityHub.setMachineState(2);
return this.config.appActiveCheckInterval * 1000;
}
}

function setActivityHandlers(self) {
Expand Down
2 changes: 1 addition & 1 deletion app/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function argv(configPath, appVersion) {

logger.init(config.logConfig);

console.debug('configPath:', configPath);
console.info('configPath:', configPath);
console.debug('configFile:', configObject.configFile);

return config;
Expand Down
2 changes: 1 addition & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function handleCertificateError() {
}

async function requestMediaAccess() {
['camera', 'microphone', 'screen'].map(async (permission) => {
['camera', 'microphone', 'screen'].forEach(async (permission) => {
const status = await
systemPreferences.askForMediaAccess(permission)
.catch(err => {
Expand Down
6 changes: 6 additions & 0 deletions app/mainAppWindow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ function onDidFinishLoad() {
`);
customCSS.onDidFinishLoad(window.webContents, config);
initSystemThemeFollow(config);
window.webContents.session.cookies.on('changed', (_event, cookie, cause, removed) => {
if ((cookie.name === 'authtoken') && (cookie.domain === 'teams.microsoft.com')) {
console.debug(`cookie changed cause: ${cause} \n removed?: ${removed} \n`);
console.debug(`cookie: ${cookie.name} \n expirationDate: ${cookie.expirationDate} \n domain: ${cookie.domain}`);
}
});
}

function initSystemThemeFollow(config) {
Expand Down
4 changes: 1 addition & 3 deletions app/menus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ To access the main menu, press the 'Alt' key while the application is selected.

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

* 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.
* Help: The help menu is defined in the [help.js](help.js) file.
* Preferences: The preferences submenu gets defined in the [preferences.js](preferences.js) file.
* 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.
* Tray: [tray.js](tray.js) contains the tray menu and its implementation.
52 changes: 44 additions & 8 deletions app/menus/application.js → app/menus/appMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { shell } = require('electron');

exports = module.exports = (Menus) => ({
label: 'Application',
label: 'Teams for Linux',
submenu: [
{
label: 'Open',
Expand All @@ -25,10 +27,19 @@ exports = module.exports = (Menus) => ({
type: 'separator',
},
getSettingsMenu(Menus),
getPreferencesMenu(),
getNotificationsMenu(Menus),
{
type: 'separator',
},
{
label: 'About',
click: () => Menus.about(),
},
getHelpMenu(),
{
type: 'separator',
},
{
label: 'Quit',
accelerator: 'ctrl+Q',
Expand All @@ -38,13 +49,6 @@ exports = module.exports = (Menus) => ({
label: 'Quit (Clear Storage)',
click: () => Menus.quit(true)
},
{
type: 'separator',
},
{
label: 'About',
click: () => Menus.about(),
}
],
});

Expand All @@ -64,6 +68,18 @@ function getSettingsMenu(Menus) {
};
}

function getPreferencesMenu() {
return {
label: 'Zoom',
submenu: [
{role: 'resetZoom'},
{role: 'zoomIn'},
{role: 'zoomOut'},
{role: 'togglefullscreen'},
],
}
}

function getNotificationsMenu(Menus) {
return {
label: 'Notifications',
Expand Down Expand Up @@ -124,3 +140,23 @@ function getNotificationsMenu(Menus) {
]
};
}

function getHelpMenu () {
return {
label: 'Help',
submenu: [
{
label: 'Online Documentation',
click: () => shell.openExternal('https://support.office.com/en-us/teams'),
},
{
label: 'Github Project',
click: () => shell.openExternal('https://github.com/IsmaelMartinez/teams-for-linux'),
},
{
label: 'Microsoft Teams Support',
click:() => shell.openExternal('https://answers.microsoft.com/en-us/msteams/forum'),
},
],
};
}
25 changes: 0 additions & 25 deletions app/menus/help.js

This file was deleted.

24 changes: 7 additions & 17 deletions app/menus/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const { app, Menu, MenuItem, clipboard, dialog, session, ipcMain } = require('electron');
const fs = require('fs'),
path = require('path');
const application = require('./application');
const preferences = require('./preferences');
const help = require('./help');
const appMenu = require('./appMenu');
const Tray = require('./tray');
const { SpellCheckProvider } = require('../spellCheckProvider');
const connectionManager = require('../connectionManager');
Expand Down Expand Up @@ -93,21 +91,17 @@ class Menus {
}

initialize() {
const appMenu = application(this);
const menu = appMenu(this);

if (this.configGroup.startupConfig.menubar == 'hidden') {
this.window.removeMenu();
} else {
this.window.setMenu(Menu.buildFromTemplate([
appMenu,
preferences(),
help(app, this.window),
]));
this.window.setMenu(Menu.buildFromTemplate([menu]));
}

this.initializeEventHandlers();

this.tray = new Tray(this.window, appMenu.submenu, this.iconPath, this.configGroup.startupConfig);
this.tray = new Tray(this.window, menu.submenu, this.iconPath, this.configGroup.startupConfig);
this.spellCheckProvider = new SpellCheckProvider(this.window);
}

Expand Down Expand Up @@ -144,13 +138,9 @@ class Menus {
}

updateMenu() {
const appMenu = application(this);
this.window.setMenu(Menu.buildFromTemplate([
appMenu,
preferences(),
help(app, this.window),
]));
this.tray.setContextMenu(appMenu.submenu);
const menu = appMenu(this);
this.window.setMenu(Menu.buildFromTemplate([menu]));
this.tray.setContextMenu(menu.submenu);
}

toggleDisableNotifications() {
Expand Down
14 changes: 0 additions & 14 deletions app/menus/preferences.js

This file was deleted.

11 changes: 11 additions & 0 deletions com.github.IsmaelMartinez.teams_for_linux.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
<url type="bugtracker">https://github.com/IsmaelMartinez/teams-for-linux/issues</url>
<launchable type="desktop-id">com.github.IsmaelMartinez.teams_for_linux.desktop</launchable>
<releases>
<release version="1.11.2" date="2024-10-16">
<description>
<ul>
<li>Modifying the menu to include zoom, and help sections</li>
<li>Fix some sonarcloud detected issues</li>
<li>Add debug log for cookie change for authtoken and domain teams.microsoft.com</li>
<li>Updated electron to 32.2.0</li>
<li>Updated electron-builder 25.1.8</li>
</ul>
</description>
</release>
<release version="1.11.1" date="2024-10-03">
<description>
<ul>
Expand Down
Loading

0 comments on commit 1cbb46d

Please sign in to comment.