Skip to content

Commit b0f0af1

Browse files
authored
Merge pull request #1193 from jijojosephk/issue_1147
Now lets user choose notification method and urgency #1147
2 parents c831f5a + 9c744a9 commit b0f0af1

File tree

6 files changed

+61
-15
lines changed

6 files changed

+61
-15
lines changed

app/browser/index.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,24 @@
2525
}
2626
options = options || {};
2727
options.icon = options.icon ? options.icon : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAdhwAAHYcBj+XxZQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAZSSURBVHic7ZtbbBRVGMf/35nZ3RZoacPuQgqRGC6KRCUGTYWIiCRCqiGEFlEpRowYAvRFo4G2uMhu1Zj4YGMMJiRGUmhttYECvpjIRSJKguFiakBCuARpdy30QunuzsznQ3crdK8zO7tDZH8vnT3nfJfznducM6dAnvsbstL4uh1scwa6ZwmNpgCAJvhqwOnu/OptCufKB0sCsLnBP1OovAWgZQBKRmXfAHifJlHDR1tc57LtS24DwEy12wMeELYAkFOUDhPQ4K1zbgMRZ8ul3AWAmWq9gSYAr+gRI2C3t865OltBkLKhNB610sZtIGw0IProM0cG+ehPnx423SnkqAcMj3mcBWAzqEIh0GPeemenmX4BqcehKUQmPKOVBwCZCe8BeCNZoeXVx9yaItcQUAFgRiT5HIgPkKQ2tu+a3z1aJus9YN0Otrm6A10ASjNUddPvdroTLZHLX/21ihk7ARQlkO9n5rV7m8vb7kwUGTqVkold3Y8g88oDQIkz0D0rXkak8i1IXHkAKCKib5etOl55Z2LWA6AylZmlS2ixupZXH3NHWj6d3kxEtLOq6qRrRKdZziVCCJi2fGkax+jSFLkGyVt+NMVhKbQp+iPrASDmv83SJRFfi9EPvKhbEdGITNZXgT+1QGfZoNoLiPFJHIIs2eEoKAZRwjbpkbSJ8ZbBaQbcmh59yHoPaPXMDgHiYNJCz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1RNqdYrV1hYgpLSqcaMMj7zbXW9Y0zY5M2QbJc8YCS86TQaIoGCgvEoHj/ZqMmgqimNqYsl8SET4XjUev1bwdhmtt64ENf76tzeTFSY/ipsU5wNAH4zW28cTvldrk8yVWJ6ADweUgjqKgaumq07CgNXQeIlM/67LCubIW/9pIsCvIiBmLu9JtAlsVjiq5twxQxlWdsNeuvd54nkeQAfN0snAydsqpi7feuEP8zSmdXtsK+u9JLf7VpAIB+A2xmoGgST164OLPB4Jpg6tHJ2i8nj8ZeFZd4MpjUA0n3juQlCs00RPrMrHiXn17g2fX7eUdRfshgaLyXQLAAPAYjuhkIAOsF0GkI90lfct7+xZkbaL/p58ujnX2ufCTgt/KXpAAAAAElFTkSuQmCC';
28-
const notifSound = {
29-
type: options.type ? options.type : 'new-message',
30-
audio: 'default',
31-
title: title,
32-
body: options.body
33-
};
34-
console.log('Requesting application to play sound');
35-
ipcRenderer.invoke('play-notification-sound', notifSound);
36-
console.log('Continues to default notification workflow');
37-
return new classicNotification(title, options);
28+
options.title = options.title ? options.title : title;
29+
options.type = options.type ? options.type : 'new-message';
30+
31+
if (config.notificationMethod === 'web') {
32+
const notifSound = {
33+
type: options.type,
34+
audio: 'default',
35+
title: title,
36+
body: options.body
37+
};
38+
console.log('Requesting application to play sound');
39+
ipcRenderer.invoke('play-notification-sound', notifSound);
40+
console.log('Continues to default notification workflow');
41+
return new classicNotification(title, options);
42+
} else {
43+
ipcRenderer.invoke('show-notification', options);
44+
return { onclick: null, onclose: null, onerror: null, onclose: onshow };
45+
}
3846
}
3947
static requestPermission(callback) {
4048
if (typeof (callback) == 'function') {

app/config/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Here is the list of available arguments and its usage:
2323
| customBGServiceBaseUrl | Base URL of the server which provides custom background images | string |
2424
| customBGServiceIgnoreMSDefaults | A flag indicates whether to ignore Microsoft provided images or not | false |
2525
| customBGServiceConfigFetchInterval | A numeric value in seconds as poll interval to download background service config download | number |
26-
| customCACertsFingerprints | Array of custom CA Certs Fingerprints to allow SSL unrecognized signer or self signed certificate | array |
26+
| customCACertsFingerprints | Array of custom CA Certs Fingerprints to allow SSL unrecognized signer or self signed certificate | [] |
2727
| customCSSName | custom CSS name for the packaged available css files | string |
2828
| customCSSLocation | custom CSS styles file location | string |
2929
| followSystemTheme | Follow system theme | false |
@@ -49,13 +49,15 @@ Here is the list of available arguments and its usage:
4949
| optInTeamsV2 | Opt in to use Teams V2 | false |
5050
| partition | BrowserWindow webpreferences partition | string |
5151
| proxyServer | Proxy Server with format address:port | string |
52-
| screenLockInhibitionMethod | Screen lock inhibition method to be used (Electron/WakeLockSentinel) | string |
53-
| spellCheckerLanguages | Array of languages to use with Electron's spell checker (experimental) | array |
52+
| screenLockInhibitionMethod | Screen lock inhibition method to be used (`Electron`/`WakeLockSentinel`) | Electron |
53+
| spellCheckerLanguages | Array of languages to use with Electron's spell checker | [] |
5454
| url | Microsoft Teams URL | string |
5555
| useMutationTitleLogic | Use MutationObserver to update counter from title | false |
5656
| version | Show the version number | false |
5757
| webDebug | Enable web debugging | false |
5858
| electronCLIFlags | Electron CLI flags to be added when the app starts | [] |
59+
| notificationMethod | Notification method to be used by the application (`web`/`electron`) | web |
60+
| defaultNotificationUrgency | Default urgency for new notifications (`low`/`normal`/`critical`). Only applicable when `notificationMethod` is `electron` | normal |
5961

6062

6163
As an example, to disable the persistence, you can run the following command:

app/config/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,18 @@ function argv(configPath, appVersion) {
247247
default: [],
248248
describe: "Electron CLI flags",
249249
type: 'array'
250+
},
251+
notificationMethod: {
252+
default: 'web',
253+
describe: 'Notification method to be used by the application (web/electron)',
254+
type: 'string',
255+
choices: ['web', 'electron']
256+
},
257+
defaultNotificationUrgency: {
258+
default: 'normal',
259+
describe: 'Default urgency for new notifications (low/normal/critical)',
260+
type: 'string',
261+
choices: ['low', 'normal', 'critical']
250262
}
251263
})
252264
.parse(process.argv.slice(1));

app/index.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { app, ipcMain, desktopCapturer, systemPreferences, powerMonitor } = require('electron');
1+
const { app, ipcMain, desktopCapturer, systemPreferences, powerMonitor, Notification, nativeImage } = require('electron');
22
const path = require('path');
33
const fs = require('fs');
44
const { LucidLog } = require('lucid-log');
@@ -83,6 +83,7 @@ if (!gotTheLock) {
8383
ipcMain.handle('desktopCapturerGetSources', (event, opts) => desktopCapturer.getSources(opts));
8484
ipcMain.handle('getCustomBGList', handleGetCustomBGList);
8585
ipcMain.handle('play-notification-sound', playNotificationSound);
86+
ipcMain.handle('show-notification', showNotification);
8687
ipcMain.handle('user-status-changed', userStatusChangedHandler);
8788
ipcMain.handle('set-badge-count', setBadgeCountHandler);
8889
}
@@ -154,6 +155,22 @@ function addElectronCLIFlagsFromConfig() {
154155
}
155156
}
156157

158+
async function showNotification(event, options) {
159+
logger.debug('Showing notification using electron API');
160+
playNotificationSound(null, {
161+
type: options.type,
162+
audio: 'default',
163+
title: options.title,
164+
body: options.body
165+
});
166+
new Notification({
167+
icon: nativeImage.createFromDataURL(options.icon),
168+
title: options.title,
169+
body: options.body,
170+
urgency: config.defaultNotificationUrgency
171+
}).show();
172+
}
173+
157174
// eslint-disable-next-line no-unused-vars
158175
async function playNotificationSound(event, options) {
159176
logger.debug(`Notificaion => Type: ${options.type}, Audio: ${options.audio}, Title: ${options.title}, Body: ${options.body}`);

com.github.IsmaelMartinez.teams_for_linux.appdata.xml

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
<url type="bugtracker">https://github.com/IsmaelMartinez/teams-for-linux/issues</url>
1515
<launchable type="desktop-id">com.github.IsmaelMartinez.teams_for_linux.desktop</launchable>
1616
<releases>
17+
<release version="1.4.25" date="2024-04-14">
18+
<description>
19+
<ul>
20+
<li>Now lets user choose the notification method and urgency</li>
21+
</ul>
22+
</description>
23+
</release>
1724
<release version="1.4.24" date="2024-04-13">
1825
<description>
1926
<ul>

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.24",
3+
"version": "1.4.25",
44
"main": "app/index.js",
55
"description": "Unofficial client for Microsoft Teams for Linux",
66
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",

0 commit comments

Comments
 (0)