Merge pull request #1258 from johankwarnmarksymphony/sda3312

fix: Clean up after new locale is set
This commit is contained in:
Johan Kwarnmark 2021-08-31 14:35:08 +02:00 committed by GitHub
commit 7abf2531c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 19 deletions

View File

@ -32,6 +32,7 @@ import { screenSnippet } from './screen-snippet-handler';
import { updateAlwaysOnTop } from './window-actions';
import { ICustomBrowserWindow, windowHandler } from './window-handler';
import { notification } from '../renderer/notification';
interface IStyles {
name: styleNames;
content: string;
@ -293,6 +294,9 @@ export const updateLocale = async (locale: LocaleType): Promise<void> => {
appMenu.update(locale);
}
// Update notification after new locale
notification.cleanUpInactiveNotification();
if (i18n.isValidLocale(locale)) {
// Update user config file with latest locale changes
await config.updateUserConfig({ locale });

View File

@ -427,6 +427,25 @@ class Notification extends NotificationHandler {
this.inactiveWindows = [];
}
/**
* Closes the active notification after certain period
*/
public cleanUpInactiveNotification() {
if (this.inactiveWindows.length > 0) {
logger.info('notification: cleaning up inactive notification windows', {
inactiveNotification: this.inactiveWindows.length,
});
this.inactiveWindows.forEach((window) => {
if (windowExists(window)) {
window.close();
}
});
logger.info(`notification: cleaned up inactive notification windows`, {
inactiveNotification: this.inactiveWindows.length,
});
}
}
/**
* Brings all the notification to the top
* issue: ELECTRON-1382
@ -508,25 +527,6 @@ class Notification extends NotificationHandler {
this.activeNotifications.push(notificationWindow);
}
/**
* Closes the active notification after certain period
*/
private cleanUpInactiveNotification() {
if (this.inactiveWindows.length > 0) {
logger.info('notification: cleaning up inactive notification windows', {
inactiveNotification: this.inactiveWindows.length,
});
this.inactiveWindows.forEach((window) => {
if (windowExists(window)) {
window.close();
}
});
logger.info(`notification: cleaned up inactive notification windows`, {
inactiveNotification: this.inactiveWindows.length,
});
}
}
/**
* Clears the timer for a specific notification window
*