Skip to content

Commit dfab5ad

Browse files
adding how to debug in bug report, moving react logic into its own ha… (#1176)
* adding how to debug in bug report, moving react logic into its own handler, moving theme.js to use react instead of angular, change regex in mainAppWindow to allow for v1 and v2 versions and removing some rough lines * adding some extra escape characters for the dots in the url
1 parent 134d579 commit dfab5ad

File tree

17 files changed

+91
-76
lines changed

17 files changed

+91
-76
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+9
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,14 @@ If applicable, add screenshots to help explain your problem.
2828
- Installation package [deb, rpm, snap, AppImage, tar.gz, source...]
2929
- Version [e.g. 0.1.17]
3030

31+
**Debug**
32+
When possible, please run the application from the terminal using `--webDebug` and try to reproduce the error.
33+
34+
The provide in this section the output from both the terminal and the browser debug console.
35+
36+
```bash
37+
teams-for-linux --webDebug --appLogLevels=error,info,warn,debug
38+
```
39+
3140
**Additional context**
3241
Add any other context about the problem here.

app/appConfiguration/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ class AppConfiguration {
4747
}
4848
}
4949

50-
module.exports = { AppConfiguration };
50+
module.exports = { AppConfiguration };

app/browser/tools/activityHub.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const instance = require('./instance');
2+
const ReactHandler = require('./reactHandler');
23
/**
34
* @type {Array<{handler:(data)=>void,event:string,handle:number}>}
45
*/
@@ -56,7 +57,7 @@ class ActivityHub {
5657
* @param {number} state
5758
*/
5859
setMachineState(state) {
59-
const teams2IdleTracker = instance.getTeams2IdleTracker();
60+
const teams2IdleTracker = ReactHandler.getTeams2IdleTracker();
6061
if (teams2IdleTracker) {
6162
try {
6263
console.log(`setMachineState teams2 state=${state}`);

app/browser/tools/instance.js

-12
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ class Instance {
1515
return await this.whenReady(tries + 1);
1616
}
1717
}
18-
19-
getTeams2ReactElement() {
20-
return document.getElementById('app');
21-
}
22-
23-
getTeams2CoreServices() {
24-
return this.getTeams2ReactElement()?._reactRootContainer?._internalRoot?.current?.updateQueue?.baseState?.element?.props?.coreServices;
25-
}
26-
27-
getTeams2IdleTracker() {
28-
return this.getTeams2CoreServices()?.clientState?._idleTracker;
29-
}
3018
}
3119

3220
function getAppObjects() {

app/browser/tools/reactHandler.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class ReactHandler {
2+
3+
_getTeams2ReactElement() {
4+
return document.getElementById('app');
5+
}
6+
7+
_getTeams2CoreServices() {
8+
return this._getTeams2ReactElement()?._reactRootContainer?._internalRoot?.current?.updateQueue?.baseState?.element?.props?.coreServices;
9+
}
10+
11+
getTeams2IdleTracker() {
12+
return this._getTeams2CoreServices()?.clientState?._idleTracker;
13+
}
14+
15+
getTeams2ClientPreferences() {
16+
return this._getTeams2CoreServices()?.clientPreferences?.clientPreferences;
17+
}
18+
}
19+
20+
module.exports = new ReactHandler();

app/browser/tools/theme.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const instance = require('./instance');
1+
const ReactHandler = require('./reactHandler');
22

33
class ThemeManager {
44
/**
@@ -8,17 +8,18 @@ class ThemeManager {
88
init(config, ipcRenderer) {
99
this.ipcRenderer = ipcRenderer;
1010
this.config = config;
11+
ReactHandler.getTeams2ClientPreferences().followOsTheme = config.followSystemTheme;
1112
if (config.followSystemTheme) {
12-
this.ipcRenderer.on('system-theme-changed', this.applyTheme);
13+
console.log('followSystemTheme', config.followSystemTheme);
14+
this.ipcRenderer.on('system-theme-changed', this.applyTheme);
1315
}
1416
}
1517

1618
applyTheme = async (event, ...args) => {
1719
const theme = args[0] ? 'dark' : 'default';
18-
const inst = await instance.whenReady().catch(() => {
19-
console.error('Failed to apply Theme');
20-
});
21-
inst.controller.layoutService.setTheme(theme);
20+
const clientPreferences = ReactHandler.getTeams2ClientPreferences();
21+
clientPreferences.useTheme = theme;
22+
console.log('Theme changed to', theme);
2223
}
2324
}
2425

app/browser/tools/wakeLock.js

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
var _WakeLock_lock = new WeakMap();
22
class WakeLock {
3-
constructor() {
4-
_WakeLock_lock.set(this, null);
5-
}
3+
constructor() {
4+
_WakeLock_lock.set(this, null);
5+
}
66

7-
async enable() {
8-
try {
9-
var lock = await navigator.wakeLock.request('screen');
10-
lock.addEventListener('release', () => {
11-
console.log('Wake Lock was released');
12-
});
13-
console.log('Wake Lock is active');
14-
_WakeLock_lock.set(this, lock);
7+
async enable() {
8+
try {
9+
var lock = await navigator.wakeLock.request('screen');
10+
lock.addEventListener('release', () => {
11+
console.log('Wake Lock was released');
12+
});
13+
console.log('Wake Lock is active');
14+
_WakeLock_lock.set(this, lock);
1515

16-
} catch (err) {
17-
console.error(`${err.name}, ${err.message}`);
18-
}
19-
}
16+
} catch (err) {
17+
console.error(`${err.name}, ${err.message}`);
18+
}
19+
}
2020

21-
async disable() {
22-
var lock = _WakeLock_lock.get(this);
23-
if (!lock) {
24-
return;
25-
}
26-
try {
27-
await lock.release();
28-
lock = null;
29-
_WakeLock_lock.set(this, lock);
30-
} catch (err) {
31-
console.error(`${err.name}, ${err.message}`);
32-
}
33-
}
21+
async disable() {
22+
var lock = _WakeLock_lock.get(this);
23+
if (!lock) {
24+
return;
25+
}
26+
try {
27+
await lock.release();
28+
lock = null;
29+
_WakeLock_lock.set(this, lock);
30+
} catch (err) {
31+
console.error(`${err.name}, ${err.message}`);
32+
}
33+
}
3434
}
3535

3636
const wakeLock = new WakeLock();

app/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,4 @@ function onCustomBGServiceConfigDownloadFailure(err) {
335335
catch (err) {
336336
logger.error(`Failed to save remote configuration at '${dlpath}'`);
337337
}
338-
}
338+
}

app/mainAppWindow/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ function restoreWindow() {
222222
}
223223

224224
function processArgs(args) {
225-
var regHttps = /^https:\/\/teams.microsoft.com\/l\/(meetup-join|channel)\//g;
226-
var regMS = /^msteams:\/l\/(meetup-join|channel)\//g;
225+
var regHttps = /^https:\/\/teams\.microsoft\.com\/.*(?:meetup-join|channel)/g;
226+
var regMS = /^msteams:\/.*(?:meetup-join|channel)/g;
227227
logger.debug('processArgs:', args);
228228
for (const arg of args) {
229229
if (regHttps.test(arg)) {
@@ -317,7 +317,7 @@ function onBeforeSendHeadersHandler(detail, callback) {
317317
* @returns {{action: 'deny'} | {action: 'allow', outlivesOpener?: boolean, overrideBrowserWindowOptions?: Electron.BrowserWindowConstructorOptions}}
318318
*/
319319
function onNewWindow(details) {
320-
if (details.url.startsWith('https://teams.microsoft.com/l/meetup-join')) {
320+
if (details.url.startsWith('https://teams.microsoft.com/l/meetup-join') || details.url.startsWith('https://teams.microsoft.com/v2/l/meetup-join')) {
321321
logger.debug('DEBUG - captured meetup-join url');
322322
return { action: 'deny' };
323323
} else if (details.url === 'about:blank' || details.url === 'about:blank#blocked') {
@@ -619,4 +619,4 @@ function enableWakeLockOnWindowRestore() {
619619
if (isOnCall) {
620620
window.webContents.send('enable-wakelock');
621621
}
622-
}
622+
}

app/menus/application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ function getNotificationsMenu(Menus) {
109109
}
110110
]
111111
};
112-
}
112+
}

app/menus/tray.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ class ApplicationTray {
3434
this.tray.destroy();
3535
}
3636
}
37-
exports = module.exports = ApplicationTray;
37+
exports = module.exports = ApplicationTray;

app/spellCheckProvider/codes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -701,4 +701,4 @@ const codes = [
701701
}
702702
];
703703

704-
module.exports = codes;
704+
module.exports = codes;

app/spellCheckProvider/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,4 @@ function stringCompare(str1, str2) {
136136
return le ? -1 : gr ? 1 : 0;
137137
}
138138

139-
module.exports = { SpellCheckProvider };
139+
module.exports = { SpellCheckProvider };

app/streamSelector/browser.js

-1
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,3 @@ function createQualitySelector(properties) {
123123
defaultSelection = defaultSelection > -1 ? defaultSelection : properties.screens.length - 1;
124124
properties.sscontainer.selectedIndex = defaultSelection;
125125
}
126-

app/streamSelector/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,3 @@ function createScreenRequestHandler() {
151151
}
152152

153153
module.exports = { StreamSelector };
154-
155-

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "teams-for-linux",
3-
"version": "1.4.17",
3+
"version": "1.4.18",
44
"main": "app/index.js",
55
"description": "Unofficial client for Microsoft Teams for Linux",
66
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",

scripts/afterpack.js

+14-15
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ const {flipFuses, FuseVersion, FuseV1Options} = require('@electron/fuses');
22
const {chmod} = require('fs/promises');
33

44
function getAppFileName(context) {
5-
const productFileName = context.packager.appInfo.productFilename
5+
const productFileName = context.packager.appInfo.productFilename;
66

77
switch (context.electronPlatformName) {
8-
case 'win32':
9-
return `${productFileName}.exe`;
10-
case 'darwin':
11-
return `${productFileName}.app`;
12-
case 'mas':
13-
return `${productFileName}.app`;
14-
case 'linux':
15-
return context.packager.executableName;
16-
default:
17-
return '';
8+
case 'win32':
9+
return `${productFileName}.exe`;
10+
case 'darwin':
11+
return `${productFileName}.app`;
12+
case 'mas':
13+
return `${productFileName}.app`;
14+
case 'linux':
15+
return context.packager.executableName;
16+
default:
17+
return '';
1818
}
1919
}
2020

@@ -25,11 +25,10 @@ exports.default = async function afterPack(context) {
2525
await flipFuses(
2626
path,
2727
{
28-
version: FuseVersion.V1,
29-
[FuseV1Options.EnableCookieEncryption]: true,
28+
version: FuseVersion.V1,
29+
[FuseV1Options.EnableCookieEncryption]: true,
3030
},
31-
);
32-
31+
);
3332
} catch (error) {
3433
console.error('afterPack error: ', error);
3534
process.exit(1);

0 commit comments

Comments
 (0)