Files
mattermostest/src/main/notifications/Upgrade.ts
Devin Binnie 59e4e7e516 [MM-14058] Add support for i18n (#2190)
* Add language files

* Add react-intl, mmjstool, setup for adding translations

* Translated main module

* Translations for renderer

* A few minor fixes

* More fixes

* Add CI, add missing menu translations, other cleanup

* Added setting to manually select the language of the app

* Force English for E2e

* Unit tests

* Fix mmjstool

* Move set language to before update menu

* PR feedback
2022-07-14 11:04:18 -04:00

50 lines
1.8 KiB
TypeScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import path from 'path';
import {app, Notification} from 'electron';
import {localizeMessage} from 'main/i18nManager';
const assetsDir = path.resolve(app.getAppPath(), 'assets');
const appIconURL = path.resolve(assetsDir, 'appicon_48.png');
const defaultOptions = {
title: localizeMessage('main.notifications.upgrade.newVersion.title', 'New desktop version available'),
body: localizeMessage('main.notifications.upgrade.newVersion.body', 'A new version is available for you to download now.'),
silent: false,
icon: appIconURL,
urgency: 'normal' as Notification['urgency'],
};
export class NewVersionNotification extends Notification {
constructor() {
const options = {...defaultOptions};
if (process.platform === 'win32') {
options.icon = appIconURL;
} else if (process.platform === 'darwin') {
// Notification Center shows app's icon, so there were two icons on the notification.
Reflect.deleteProperty(options, 'icon');
}
super(options);
}
}
export class UpgradeNotification extends Notification {
constructor() {
const options = {...defaultOptions};
options.title = localizeMessage('main.notifications.upgrade.readyToInstall.title', 'Click to restart and install update');
options.body = localizeMessage('main.notifications.upgrade.readyToInstall.body', 'A new desktop version is ready to install now.');
if (process.platform === 'win32') {
options.icon = appIconURL;
} else if (process.platform === 'darwin') {
// Notification Center shows app's icon, so there were two icons on the notification.
Reflect.deleteProperty(options, 'icon');
}
super(options);
}
}