Skip to content

Show error message if configuration is invalid #1224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading