Commit 689488b6 authored by Tasso Evangelista's avatar Tasso Evangelista

Remove electron-windows-notifications

parent 0b044628
const fs = require('fs');
const path = require('path');
const patchWindowsDLLs = ({ appOutDir, x64 }) => {
fs.copyFileSync(path.join(__dirname, x64 ? 'x64' : 'ia32', 'vccorlib140.dll'),
path.join(appOutDir, 'vccorlib140.dll'));
};
exports.default = (context) => {
const { appOutDir, arch, packager: { platform: { nodeName } } } = context;
if (nodeName === 'win32') {
patchWindowsDLLs({ appOutDir, x64: arch === 1 });
}
};
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
"servers.json" "servers.json"
], ],
"appId": "chat.rocket", "appId": "chat.rocket",
"afterPack": "./build/afterPack.js",
"mac": { "mac": {
"category": "public.app-category.productivity", "category": "public.app-category.productivity",
"target": [ "target": [
......
import { app, ipcMain, Notification } from 'electron'; import { app, ipcMain, Notification } from 'electron';
import { ToastNotification } from 'electron-windows-notifications';
import freedesktopNotifications from 'freedesktop-notifications'; import freedesktopNotifications from 'freedesktop-notifications';
import os from 'os'; import os from 'os';
import path from 'path'; import path from 'path';
...@@ -65,51 +64,6 @@ class ElectronNotification extends BaseNotification { ...@@ -65,51 +64,6 @@ class ElectronNotification extends BaseNotification {
} }
class WindowsToastNotification extends BaseNotification {
initialize({ title, body, icon, silent, tag } = {}) {
const strings = [
title && (title.length > 100 ? `${ title.substring(0, 100 - 3) }...` : title),
body && (body.length > 1000 ? `${ body.substring(0, 1000 - 3) }...` : body),
icon,
].filter(Boolean);
this.notification = new ToastNotification({
template: `
<toast>
<visual>
<binding template="ToastGeneric">
${ title ? '<text>%s</text>' : '' }
${ body ? '<text>%s</text>' : '' }
${ icon ? '<image placement="AppLogoOverride" src="%s" />' : '' }
</binding>
</visual>
${ silent ? '<audio silent="true" />' : '' }
</toast>`,
strings,
tag: tag ? `${ tag.slice(0, 16) }` : undefined,
appId: 'chat.rocket',
});
this.notification.on('activated', this.handleClick);
this.notification.on('dismissed', this.handleClose);
}
reset(options = {}) {
this.notification.removeAllListeners();
this.initialize(options);
}
show() {
this.notification.show();
this.handleShow();
}
close() {
this.notification.hide();
}
}
class FreeDesktopNotification extends BaseNotification { class FreeDesktopNotification extends BaseNotification {
escapeBody(body) { escapeBody(body) {
const escapeMap = { const escapeMap = {
...@@ -166,10 +120,6 @@ const ImplementatedNotification = (() => { ...@@ -166,10 +120,6 @@ const ImplementatedNotification = (() => {
return FreeDesktopNotification; return FreeDesktopNotification;
} }
if (os.platform() === 'win32' && os.release().split('.').slice(0, 2).join('.') !== '6.1') {
return WindowsToastNotification;
}
return ElectronNotification; return ElectronNotification;
})(); })();
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment