Skip to content

Commit

Permalink
Merge branch 'release/2.14.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Nov 14, 2018
2 parents 59e653e + 74e929b commit cf42b86
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="2.14.3"></a>
## 2.14.3 (2018-11-14)


### Bug Fixes

- [#978](https://github.com/RocketChat/Rocket.Chat.Electron/pull/978) Fallback notifications for Windows 7



<a name="2.14.2"></a>
## 2.14.2 (2018-11-13)

Expand Down
2 changes: 1 addition & 1 deletion electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"mas"
],
"icon": "build/icon.icns",
"bundleVersion": "40",
"bundleVersion": "41",
"helperBundleId": "chat.rocket.electron.helper",
"type": "distribution",
"artifactName": "rocketchat-${version}.${ext}"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "rocketchat",
"productName": "Rocket.Chat",
"description": "Rocket.Chat Native Cross-Platform Desktop Application via Electron.",
"version": "2.14.2",
"version": "2.14.3",
"author": "Rocket.Chat Support <[email protected]>",
"copyright": "© 2018, Rocket.Chat",
"homepage": "https://rocket.chat",
Expand Down
51 changes: 49 additions & 2 deletions src/background/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { app, ipcMain, Notification as ElectronNotification } from 'electron';
import { ToastNotification } from 'electron-windows-notifications';
import { EventEmitter } from 'events';
import freedesktopNotifications from 'freedesktop-notifications';
import os from 'os';
import path from 'path';


Expand Down Expand Up @@ -141,11 +142,57 @@ class WindowsNotification extends BaseNotification {
}
}

class Windows7Notification extends BaseNotification {
constructor({ title, body, icon, tag } = {}) {
super();

Windows7Notification.instances = Windows7Notification.instances || {};

this.previousNotification = tag && Windows7Notification.instances[tag];

const notification = new ElectronNotification({
title,
body,
icon: icon && path.resolve(icon),
});

notification.on('show', () => this.emit('show'));
notification.on('close', () => {
if (tag) {
delete Windows7Notification.instances[tag];
}

this.emit('close');
});
notification.on('click', () => this.emit('click'));

app.on('before-quit', () => notification.close());

if (tag) {
Windows7Notification.instances[tag] = notification;
}

this.notification = notification;
}

show() {
if (this.previousNotification) {
this.previousNotification.close();
}

this.notification.show();
}

close() {
this.notification.close();
}
}

class Notification extends ({
darwin: MacNotification,
linux: LinuxNotification,
win32: WindowsNotification,
}[process.platform]) {}
win32: os.release().split('.').slice(0, 2).join('.') === '6.1' ? Windows7Notification : WindowsNotification,
}[os.platform()]) {}

const notifications = [];

Expand Down

0 comments on commit cf42b86

Please sign in to comment.