[MM-38679] Fix download notification title on Windows (#1752)

* [MM-38679] Fix download notification title on Windows

* Lint fix
This commit is contained in:
Devin Binnie
2021-09-22 12:41:28 -04:00
committed by GitHub
parent f8209540e3
commit 45ff8cbd9f
3 changed files with 5 additions and 7 deletions

View File

@@ -759,7 +759,7 @@ function initializeAfterAppReady() {
item.on('done', (doneEvent, state) => {
if (state === 'completed') {
displayDownloadCompleted(filename, item.savePath, urlUtils.getView(webContents.getURL(), config.teams)!);
displayDownloadCompleted(filename, item.savePath, WindowManager.getServerNameByWebContentsId(webContents.id) || '');
}
});
});

View File

@@ -3,7 +3,6 @@
import path from 'path';
import {app, Notification} from 'electron';
import {ServerFromURL} from 'types/utils';
const assetsDir = path.resolve(app.getAppPath(), 'assets');
const appIconURL = path.resolve(assetsDir, 'appicon_48.png');
@@ -17,7 +16,7 @@ const defaultOptions = {
};
export class DownloadNotification extends Notification {
constructor(fileName: string, serverInfo: ServerFromURL) {
constructor(fileName: string, serverName: string) {
const options = {...defaultOptions};
if (process.platform === 'win32') {
options.icon = appIconURL;
@@ -26,7 +25,7 @@ export class DownloadNotification extends Notification {
Reflect.deleteProperty(options, 'icon');
}
options.title = process.platform === 'win32' ? serverInfo.name : 'Download Complete';
options.title = process.platform === 'win32' ? serverName : 'Download Complete';
options.body = process.platform === 'win32' ? `Download Complete \n ${fileName}` : fileName;
super(options);

View File

@@ -5,7 +5,6 @@ import {shell, Notification} from 'electron';
import log from 'electron-log';
import {MentionData} from 'types/notification';
import {ServerFromURL} from 'types/utils';
import {PLAY_SOUND} from 'common/communication';
import {TAB_MESSAGING} from 'common/tabs/TabView';
@@ -60,12 +59,12 @@ export function displayMention(title: string, body: string, channel: {id: string
mention.show();
}
export function displayDownloadCompleted(fileName: string, path: string, serverInfo: ServerFromURL) {
export function displayDownloadCompleted(fileName: string, path: string, serverName: string) {
if (!Notification.isSupported()) {
log.error('notification not supported');
return;
}
const download = new DownloadNotification(fileName, serverInfo);
const download = new DownloadNotification(fileName, serverName);
download.on('show', () => {
windowManager.flashFrame(true);