Skip to content

Commit

Permalink
Merge pull request #931 from jijojosephk/issue-918
Browse files Browse the repository at this point in the history
Fix: #918
  • Loading branch information
jijojosephk authored Aug 20, 2023
2 parents 00fd274 + 2a8a006 commit f9abf9b
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 150 deletions.
2 changes: 0 additions & 2 deletions app/browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ The files in here handle the code that talks with the browser page.

The [index.js](index.js) is the entry point.

The [onlineOfflineListener.js](tools/onlineOfflineListener.js) adds listeners to the online/offline events and emit an 'online-status-changed' to the ipc when it receives a online/offline event.

The [zoom.js](tools/zoom.js) inject the keyboard shortcuts for zoom in the browser.

The notifications folder contains:
Expand Down
4 changes: 0 additions & 4 deletions app/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@
* @param {Electron.IpcRenderer} ipcRenderer
*/
function initializeModules(config, ipcRenderer) {
if (config.onlineOfflineReload) {
require('./tools/onlineOfflineListener')();
}

require('./tools/zoom').init(config);
require('./tools/shortcuts').init(config);
require('./tools/chromeApi')(config);
Expand Down
15 changes: 0 additions & 15 deletions app/browser/tools/onlineOfflineListener.js

This file was deleted.

1 change: 0 additions & 1 deletion app/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Here is the list of available arguments and its usage:
|:-:|:-:|:-:|
| help | show the available commands | false |
| version | show the version number | false |
| onlineOfflineReload | Reload page when going from offline to online | true |
| rightClickWithSpellcheck | Enable/Disable the right click menu with spellchecker | true |
| closeAppOnCross | Close the app when clicking the close (X) cross | false |
| partition | [BrowserWindow](https://electronjs.org/docs/api/browser-window) webpreferences partition | persist:teams-4-linux |
Expand Down
5 changes: 0 additions & 5 deletions app/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ function argv(configPath) {
describe: 'Close the app when clicking the close (X) cross',
type: 'boolean'
},
onlineOfflineReload: {
default: false,
describe: 'Reload page when going from offline to online',
type: 'boolean'
},
url: {
default: 'https://teams.microsoft.com/',
describe: 'Microsoft Teams URL',
Expand Down
68 changes: 67 additions & 1 deletion app/connectionManager/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const { ipcMain, powerMonitor } = require('electron');
const { checkConnectivity } = require('../helpers');
const { LucidLog } = require('lucid-log');

let _ConnectionManager_window = new WeakMap();
let _ConnectionManager_config = new WeakMap();
let _ConnectionManager_logger = new WeakMap();
let _ConnectionManager_currentUrl = new WeakMap();
class ConnectionManager {
/**
* @returns {Electron.BrowserWindow}
Expand All @@ -15,15 +21,75 @@ class ConnectionManager {
return _ConnectionManager_config.get(this);
}

/**
* @returns {LucidLog}
*/
get logger() {
return _ConnectionManager_logger.get(this);
}

/**
* @returns {string}
*/
get currentUrl() {
return _ConnectionManager_currentUrl.get(this);
}

/**
* @param {string} url
* @param {{window:Electron.BrowserWindow,config:object}} options
*/
start(url, options) {
_ConnectionManager_window.set(this, options.window);
_ConnectionManager_config.set(this, options.config);
this.window.loadURL(url ? url : this.config.url, { userAgent: this.config.chromeUserAgent });
_ConnectionManager_logger.set(this, new LucidLog({
levels: options.config.appLogLevels.split(',')
}));
_ConnectionManager_currentUrl.set(this, url ? url : this.config.url);
ipcMain.on('offline-retry', assignOfflineRetryHandler(this));
powerMonitor.on('resume', assignSystemResumeEventHandler(this));
this.refresh();
}

async refresh() {
const currentUrl = this.window.webContents.getURL();
const hasUrl = currentUrl && currentUrl.startsWith('https://') ? true : false;
const connected = await checkConnectivity(1000, 1);
if (!connected) {
this.window.setTitle('Waiting for network...');
this.logger.debug('Waiting for network...');
}
const retryConnected = await checkConnectivity(1000, 30);
if (retryConnected) {
if (hasUrl) {
this.window.reload();
} else {
this.window.loadURL(this.currentUrl, { userAgent: this.config.chromeUserAgent });
}
} else {
this.window.setTitle('No internet connection');
this.logger.error('No internet connection');
}
}
}

/**
*
* @param {ConnectionManager} cm
*/
function assignOfflineRetryHandler(cm) {
return () => {
cm.refresh();
};
}

/**
* @param {ConnectionManager} cm
*/
function assignSystemResumeEventHandler(cm) {
return () => {
cm.refresh();
};
}

module.exports = new ConnectionManager();
73 changes: 0 additions & 73 deletions app/connectionManager/offline.html

This file was deleted.

6 changes: 0 additions & 6 deletions app/mainAppWindow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const path = require('path');
const login = require('../login');
const customCSS = require('../customCSS');
const Menus = require('../menus');
const onlineOffline = require('../onlineOffline');
const { StreamSelector } = require('../streamSelector');
const { LucidLog } = require('lucid-log');
const { SpellCheckProvider } = require('../spellCheckProvider');
Expand Down Expand Up @@ -70,7 +69,6 @@ exports.onAppReady = async function onAppReady(mainConfig) {
addEventHandlers();

const url = processArgs(process.argv);
//window.loadURL(url ? url : config.url, { userAgent: config.chromeUserAgent });
connMgr.start(url,{
window: window,
config: config
Expand Down Expand Up @@ -108,10 +106,6 @@ exports.onAppSecondInstance = function onAppSecondInstance(event, args) {
function applyAppConfiguration(config, window) {
applySpellCheckerConfiguration(config.spellCheckerLanguages, window);

if (config.onlineOfflineReload) {
onlineOffline.reloadPageWhenOfflineToOnline(window, config);
}

if (typeof config.clientCertPath !== 'undefined') {
app.importCertificate({ certificate: config.clientCertPath, password: config.clientCertPassword }, (result) => {
logger.info('Loaded certificate: ' + config.clientCertPath + ', result: ' + result);
Expand Down
24 changes: 3 additions & 21 deletions app/menus/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, Menu, MenuItem, powerMonitor, clipboard, dialog, session, ipcMain } = require('electron');
const { app, Menu, MenuItem, clipboard, dialog, session, ipcMain } = require('electron');
const fs = require('fs'),
path = require('path');
const application = require('./application');
Expand All @@ -7,7 +7,7 @@ const help = require('./help');
const Tray = require('./tray');
const { LucidLog } = require('lucid-log');
const { SpellCheckProvider } = require('../spellCheckProvider');
const { checkConnectivity } = require('../helpers');
const connectionManager = require('../connectionManager');

let _Menus_onSpellCheckerLanguageChanged = new WeakMap();
class Menus {
Expand Down Expand Up @@ -75,7 +75,7 @@ class Menus {
this.window.show();
}

this.window.reload();
connectionManager.refresh();
}

debug() {
Expand Down Expand Up @@ -109,7 +109,6 @@ class Menus {
app.on('before-quit', () => this.onBeforeQuit());
this.window.on('close', (event) => this.onClose(event));
this.window.webContents.on('context-menu', assignContextMenuHandler(this));
powerMonitor.on('resume', assignSystemResumeEventHandler(this));
}

onBeforeQuit() {
Expand Down Expand Up @@ -158,23 +157,6 @@ function restoreSettingsInternal(event, arg) {
}
}

/**
* @param {Menus} self
* @returns
*/
function assignSystemResumeEventHandler(self) {
return async () => {
self.logger.debug('Waiting for network');
const isConnected = await checkConnectivity(2000, 30);
if (isConnected) {
self.logger.debug('Reloading the page on system resume');
self.reload(false);
} else {
self.logger.error('No internet connection');
}
};
}

/**
* @param {Menus} menus
*/
Expand Down
7 changes: 0 additions & 7 deletions app/onlineOffline/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions app/onlineOffline/index.js

This file was deleted.

7 changes: 7 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,13 @@
<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.3.5" date="2023-08-20">
<description>
<ul>
<li>New: App now waits for network during start up. It waits for up to 30 seconds before becomes idle.</li>
</ul>
</description>
</release>
<release version="1.3.4" date="2023-08-18">
<description>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teams-for-linux",
"version": "1.3.4",
"version": "1.3.5",
"main": "app/index.js",
"description": "Unofficial client for Microsoft Teams for Linux",
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",
Expand Down

0 comments on commit f9abf9b

Please sign in to comment.