Skip to content

Commit

Permalink
adding tray notification for react option
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmaelMartinez committed Apr 5, 2024
1 parent 7dd0578 commit cee84ef
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function initializeModules(config, ipcRenderer) {
require('./tools/shortcuts').init(config);
require('./tools/chromeApi')(config);
require('./tools/mutationTitle').init(config);
// require('./tools/trayIconRenderer').init(config, ipcRenderer);
require('./tools/trayIconRenderer').init(config, ipcRenderer);
require('./tools/settings').init(config, ipcRenderer);
require('./tools/customBackgrounds')(config, ipcRenderer);
require('./tools/theme').init(config, ipcRenderer);
Expand Down
17 changes: 2 additions & 15 deletions app/browser/notifications/activityManager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const TrayIconRenderer = require('../tools/trayIconRenderer');
const activityHub = require('../tools/activityHub');
const wakeLock = require('../tools/wakeLock');

Expand All @@ -9,21 +8,10 @@ class ActivityManager {
*/
constructor(ipcRenderer, config) {
this.ipcRenderer = ipcRenderer;
this.iconRenderer = new TrayIconRenderer().init(config);
this.config = config;
this.myStatus = -1;
}

updateActivityCount(count) {
this.iconRenderer.render(count).then(icon => {
this.ipcRenderer.send('tray-update', {
icon: icon,
flash: (count > 0 && !this.config.disableNotificationWindowFlash)
});
});
this.ipcRenderer.invoke('set-badge-count', count);
}

start() {
setActivityHandlers(this);
setEventHandlers(this);
Expand Down Expand Up @@ -79,9 +67,8 @@ function setEventHandlers(self) {
*/
function updateActivityCountHandler() {
return async (data) => {
// const event = new CustomEvent('unread-count', { detail: { number: data.count } });
// window.dispatchEvent(event);
self.updateActivityCount(data.count);
const event = new CustomEvent('unread-count', { detail: { number: data.count } });
window.dispatchEvent(event);
};
}

Expand Down
30 changes: 15 additions & 15 deletions app/browser/tools/trayIconRenderer.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
const { nativeImage } = require('electron');
const TrayIconChooser = require('./trayIconChooser');
class TrayIconRenderer {
constructor(config) {
// init(config, ipcRenderer) {
// this.ipcRenderer = ipcRenderer;
init(config, ipcRenderer) {
this.ipcRenderer = ipcRenderer;
this.config = config;
const iconChooser = new TrayIconChooser(config);
this.baseIcon = nativeImage.createFromPath(iconChooser.getFile());
this.iconSize = this.baseIcon.getSize();
// window.addEventListener('unread-count', this.updateActivityCount.bind(this));
// }
window.addEventListener('unread-count', this.updateActivityCount.bind(this));
}

// updateActivityCount(event) {
// const count = event.detail.number;
// this.render(count).then(icon => {
// console.log('sending tray-update');
// this.ipcRenderer.send('tray-update', {
// icon: icon,
// flash: (count > 0 && !this.config.disableNotificationWindowFlash)
// });
// });
// this.ipcRenderer.invoke('set-badge-count', count);
updateActivityCount(event) {
const count = event.detail.number;
this.render(count).then(icon => {
console.log('sending tray-update');
this.ipcRenderer.send('tray-update', {
icon: icon,
flash: (count > 0 && !this.config.disableNotificationWindowFlash)
});
});
this.ipcRenderer.invoke('set-badge-count', count);
}

render(newActivityCount) {
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.18",
"version": "1.4.19",
"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 cee84ef

Please sign in to comment.