2021-02-01 20:01:25 +00:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-01-05 21:52:06 +00:00
|
|
|
import semver from 'semver';
|
|
|
|
import os from 'os';
|
|
|
|
|
2018-05-02 23:57:02 +00:00
|
|
|
import * as OS from '../OS';
|
2021-08-06 21:21:01 +00:00
|
|
|
import { isProduction } from '../util/version';
|
2018-05-02 23:57:02 +00:00
|
|
|
|
2018-05-02 23:58:23 +00:00
|
|
|
const MIN_WINDOWS_VERSION = '8.0.0';
|
|
|
|
|
2020-09-11 21:23:11 +00:00
|
|
|
export enum AudioNotificationSupport {
|
|
|
|
None,
|
|
|
|
Native,
|
|
|
|
Custom,
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getAudioNotificationSupport(): AudioNotificationSupport {
|
|
|
|
if (OS.isWindows(MIN_WINDOWS_VERSION) || OS.isMacOS()) {
|
|
|
|
return AudioNotificationSupport.Native;
|
2020-09-14 21:56:35 +00:00
|
|
|
}
|
|
|
|
if (OS.isLinux()) {
|
2020-09-11 21:23:11 +00:00
|
|
|
return AudioNotificationSupport.Custom;
|
|
|
|
}
|
|
|
|
return AudioNotificationSupport.None;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const isAudioNotificationSupported = (): boolean =>
|
|
|
|
getAudioNotificationSupport() !== AudioNotificationSupport.None;
|
2018-05-04 19:27:53 +00:00
|
|
|
|
|
|
|
// Using `Notification::tag` has a bug on Windows 7:
|
|
|
|
// https://github.com/electron/electron/issues/11189
|
2020-09-14 21:56:35 +00:00
|
|
|
export const isNotificationGroupingSupported = (): boolean =>
|
2018-05-04 19:27:53 +00:00
|
|
|
!OS.isWindows() || OS.isWindows(MIN_WINDOWS_VERSION);
|
2019-04-08 17:25:14 +00:00
|
|
|
|
2021-05-19 20:18:15 +00:00
|
|
|
// Login item settings are only supported on macOS and Windows, according to [Electron's
|
|
|
|
// docs][0].
|
|
|
|
// [0]: https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows
|
|
|
|
export const isAutoLaunchSupported = (): boolean =>
|
|
|
|
OS.isWindows() || OS.isMacOS();
|
|
|
|
|
2019-04-08 17:25:14 +00:00
|
|
|
// the "hide menu bar" option is specific to Windows and Linux
|
2020-09-14 21:56:35 +00:00
|
|
|
export const isHideMenuBarSupported = (): boolean => !OS.isMacOS();
|
2020-08-24 21:45:31 +00:00
|
|
|
|
|
|
|
// the "draw attention on notification" option is specific to Windows and Linux
|
2020-09-14 21:56:35 +00:00
|
|
|
export const isDrawAttentionSupported = (): boolean => !OS.isMacOS();
|
2021-02-01 20:01:25 +00:00
|
|
|
|
2021-06-29 17:18:03 +00:00
|
|
|
/**
|
|
|
|
* Returns `true` if you can minimize the app to the system tray. Users can override this
|
|
|
|
* option with a command line flag, but that is not officially supported.
|
|
|
|
*/
|
2021-06-29 19:29:40 +00:00
|
|
|
export const isSystemTraySupported = (appVersion: string): boolean =>
|
|
|
|
// We eventually want to support Linux in production.
|
2021-08-06 21:21:01 +00:00
|
|
|
OS.isWindows() || (OS.isLinux() && !isProduction(appVersion));
|
2021-08-20 21:41:58 +00:00
|
|
|
|
2022-09-06 22:09:52 +00:00
|
|
|
// On Windows minimize and start in system tray is default when app is selected
|
|
|
|
// to launch at login, because we can provide `['--start-in-tray']` args.
|
|
|
|
export const isMinimizeToAndStartInSystemTraySupported = (
|
|
|
|
appVersion: string
|
|
|
|
): boolean => !OS.isWindows() && isSystemTraySupported(appVersion);
|
|
|
|
|
2021-08-20 21:41:58 +00:00
|
|
|
export const isAutoDownloadUpdatesSupported = (): boolean =>
|
|
|
|
OS.isWindows() || OS.isMacOS();
|
2022-01-05 21:52:06 +00:00
|
|
|
|
|
|
|
export const shouldHideExpiringMessageBody = (): boolean =>
|
|
|
|
OS.isWindows() || (OS.isMacOS() && semver.lt(os.release(), '21.1.0'));
|