Skip to content

Commit

Permalink
Show error message if configuration is invalid (#1224)
Browse files Browse the repository at this point in the history
* Show error message if configuration is invalid

* Revert debug config path

* Apply common code style

* Apply common code style

* Update version details
  • Loading branch information
woernsn authored May 6, 2024
1 parent d3d8573 commit a78d508
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
17 changes: 11 additions & 6 deletions app/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ const { LucidLog } = require('lucid-log');
let logger;

function getConfigFile(configPath) {
try {
return require(path.join(configPath, 'config.json'));
} catch (e) {
return null;
}
return require(path.join(configPath, 'config.json'));
}

function argv(configPath, appVersion) {
let configFile = getConfigFile(configPath);
let configFile = null;
let configError = null;
try {
configFile = getConfigFile(configPath);
} catch (e) {
configError = e.message;
}
const missingConfig = configFile == null;
configFile = configFile || {};
let config = yargs
Expand Down Expand Up @@ -268,6 +270,9 @@ function argv(configPath, appVersion) {
})
.parse(process.argv.slice(1));

if (configError) {
config['error'] = configError;
}
logger = new LucidLog({
levels: config.appLogLevels.split(',')
});
Expand Down
7 changes: 6 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, ipcMain, desktopCapturer, systemPreferences, powerMonitor, Notification, nativeImage } = require('electron');
const { app, dialog, ipcMain, desktopCapturer, systemPreferences, powerMonitor, Notification, nativeImage } = require('electron');
const path = require('path');
const fs = require('fs');
const { LucidLog } = require('lucid-log');
Expand Down Expand Up @@ -217,6 +217,11 @@ function onAppTerminated(signal) {
}

function handleAppReady() {
// check for configuration errors
if (config.error) {
dialog.showErrorBox('Configuration error', config.error);
}

if (config.isCustomBackgroundEnabled) {
downloadCustomBGServiceRemoteConfig();
}
Expand Down
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.4.38" date="2024-05-06">
<description>
<ul>
<li>Show error message if configuration is invalid</li>
</ul>
</description>
</release>
<release version="1.4.37" date="2024-05-04">
<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.4.37",
"version": "1.4.38",
"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 a78d508

Please sign in to comment.