Files
zulip-desktop/app/renderer/js/utils/system-util.ts
Anders Kaseorg 220aac2d54 js: Explode singleton classes to modules.
Singleton classes may have a purpose.  This was not that purpose.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-03-04 11:54:45 -08:00

47 lines
1014 B
TypeScript

'use strict';
import { remote } from 'electron';
import os = require('os');
import ConfigUtil = require('./config-util');
const { app } = remote;
export const connectivityERR: string[] = [
'ERR_INTERNET_DISCONNECTED',
'ERR_PROXY_CONNECTION_FAILED',
'ERR_CONNECTION_RESET',
'ERR_NOT_CONNECTED',
'ERR_NAME_NOT_RESOLVED',
'ERR_NETWORK_CHANGED'
];
let userAgent: string | null = null;
export function getOS(): string {
const platform = os.platform();
if (platform === 'darwin') {
return 'Mac';
} else if (platform === 'linux') {
return 'Linux';
} else if (platform === 'win32') {
if (parseFloat(os.release()) < 6.2) {
return 'Windows 7';
} else {
return 'Windows 10';
}
} else {
return '';
}
}
export function setUserAgent(webViewUserAgent: string): void {
userAgent = `ZulipElectron/${app.getVersion()} ${webViewUserAgent}`;
}
export function getUserAgent(): string | null {
if (!userAgent) {
setUserAgent(ConfigUtil.getConfigItem('userAgent', null));
}
return userAgent;
}