From 45ff8cbd9fab3fe39a322b2196c674fbe8318fdb Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 22 Sep 2021 12:41:28 -0400 Subject: [PATCH] [MM-38679] Fix download notification title on Windows (#1752) * [MM-38679] Fix download notification title on Windows * Lint fix --- src/main/main.ts | 2 +- src/main/notifications/Download.ts | 5 ++--- src/main/notifications/index.ts | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 549edecf..19329592 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -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) || ''); } }); }); diff --git a/src/main/notifications/Download.ts b/src/main/notifications/Download.ts index c4ab1338..b1df75aa 100644 --- a/src/main/notifications/Download.ts +++ b/src/main/notifications/Download.ts @@ -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); diff --git a/src/main/notifications/index.ts b/src/main/notifications/index.ts index 90b92c6f..dd4a812b 100644 --- a/src/main/notifications/index.ts +++ b/src/main/notifications/index.ts @@ -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);