File size: 1,879 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const os = require( 'os' );

/**
 * Module variables
 */
let platform = false;

function Platform() {
	this.platform = false;
}

Platform.prototype.setMainWindow = function ( appWindow ) {
	let PlatformHandler = false;

	if ( this.isOSX() ) {
		PlatformHandler = require( './mac' );
	} else if ( this.isWindows() ) {
		PlatformHandler = require( './windows' );
	} else if ( this.isLinux() ) {
		PlatformHandler = require( './linux' );
	}

	if ( PlatformHandler ) {
		if ( this.platform ) {
			delete this.platform;
		}

		this.platform = new PlatformHandler( appWindow );

		appWindow.window.on( 'blur', () => {
			appWindow.view.webContents.send( 'notifications-panel-show', false );
		} );
	}
};

Platform.prototype.restore = function () {
	if ( this.platform ) {
		this.platform.restore();
	}
};

Platform.prototype.showNotificationsBadge = function ( count, bounceEnabled ) {
	if ( this.platform ) {
		this.platform.showNotificationsBadge( count, bounceEnabled );
	}
};

Platform.prototype.clearNotificationsBadge = function () {
	if ( this.platform ) {
		this.platform.clearNotificationsBadge();
	}
};

Platform.prototype.setDockMenu = function ( enabled ) {
	if ( this.platform ) {
		this.platform.setDockMenu( enabled );
	}
};

Platform.prototype.isOSX = function () {
	return process.platform === 'darwin';
};

Platform.prototype.isWindows = function () {
	return process.platform === 'win32';
};

Platform.prototype.isWindows10 = function () {
	return parseInt( os.release(), 10 ) >= 10 && parseInt( os.release(), 10 ) < 11;
};

Platform.prototype.isWindows11 = function () {
	return parseInt( os.release(), 11 ) >= 11;
};

Platform.prototype.isLinux = function () {
	return process.platform === 'linux';
};

Platform.prototype.getPlatformString = function () {
	return process.platform;
};

if ( ! platform ) {
	platform = new Platform();
}

module.exports = platform;