Fix issue with windows-focus-assist returning truthy value on older windows versions (#2385)
This commit is contained in:
@@ -9,6 +9,9 @@ const GNOME_READ_DND = 'gsettings get org.gnome.desktop.notifications show-banne
|
|||||||
|
|
||||||
function getLinuxDoNotDisturb() {
|
function getLinuxDoNotDisturb() {
|
||||||
try {
|
try {
|
||||||
|
if (process.platform !== 'linux') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const showNotifications = execSync(GNOME_READ_DND).toString().replace('\n', '');
|
const showNotifications = execSync(GNOME_READ_DND).toString().replace('\n', '');
|
||||||
log.debug('getLinuxDoNotDisturb', {showNotifications});
|
log.debug('getLinuxDoNotDisturb', {showNotifications});
|
||||||
|
|
||||||
|
33
src/main/notifications/dnd-windows.ts
Normal file
33
src/main/notifications/dnd-windows.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||||
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
|
import {getFocusAssist, isPriority} from 'windows-focus-assist';
|
||||||
|
|
||||||
|
/**
|
||||||
|
-2: NOT_SUPPORTED,
|
||||||
|
-1: FAILED,
|
||||||
|
0: Off,
|
||||||
|
1: PRIORITY_ONLY,
|
||||||
|
2: ALARMS_ONLY
|
||||||
|
*/
|
||||||
|
function getWindowsDoNotDisturb() {
|
||||||
|
if (process.platform !== 'win32') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const focusAssistValue = getFocusAssist().value;
|
||||||
|
switch (focusAssistValue) {
|
||||||
|
case 2:
|
||||||
|
return true;
|
||||||
|
case 1:
|
||||||
|
return !isPriority('Mattermost.Desktop');
|
||||||
|
case 0:
|
||||||
|
case -1:
|
||||||
|
case -2:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return focusAssistValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getWindowsDoNotDisturb;
|
@@ -4,7 +4,6 @@
|
|||||||
import {shell, Notification} from 'electron';
|
import {shell, Notification} from 'electron';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
|
|
||||||
import {getFocusAssist, isPriority} from 'windows-focus-assist';
|
|
||||||
import {getDoNotDisturb as getDarwinDoNotDisturb} from 'macos-notification-state';
|
import {getDoNotDisturb as getDarwinDoNotDisturb} from 'macos-notification-state';
|
||||||
|
|
||||||
import {MentionData} from 'types/notification';
|
import {MentionData} from 'types/notification';
|
||||||
@@ -18,6 +17,7 @@ import {Mention} from './Mention';
|
|||||||
import {DownloadNotification} from './Download';
|
import {DownloadNotification} from './Download';
|
||||||
import {NewVersionNotification, UpgradeNotification} from './Upgrade';
|
import {NewVersionNotification, UpgradeNotification} from './Upgrade';
|
||||||
import getLinuxDoNotDisturb from './dnd-linux';
|
import getLinuxDoNotDisturb from './dnd-linux';
|
||||||
|
import getWindowsDoNotDisturb from './dnd-windows';
|
||||||
|
|
||||||
export const currentNotifications = new Map();
|
export const currentNotifications = new Map();
|
||||||
|
|
||||||
@@ -140,13 +140,7 @@ export function displayRestartToUpgrade(version: string, handleUpgrade: () => vo
|
|||||||
|
|
||||||
function getDoNotDisturb() {
|
function getDoNotDisturb() {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
const focusAssistValue = getFocusAssist().value;
|
return getWindowsDoNotDisturb();
|
||||||
switch (focusAssistValue) {
|
|
||||||
case 1:
|
|
||||||
return !isPriority('Mattermost.Desktop');
|
|
||||||
default:
|
|
||||||
return focusAssistValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
|
Reference in New Issue
Block a user