11import { Menu , Tray , app , shell } from "electron" ;
22import { join } from "path" ;
3- import { trayManager } from ".." ;
43import { checkForUpdate , updateProcess } from "../util/updateChecker" ;
5- import { connected } from "./socketManager" ;
4+ import { connectionState as socketState } from "./socketManager" ;
5+ import { connectionState as discordState } from "./discordManager" ;
6+ import { settings } from "./settingsManager" ;
7+ import { update as updateAutoLaunch } from "./launchManager" ;
68
79export class TrayManager {
810 tray : Tray ;
@@ -14,6 +16,7 @@ export class TrayManager {
1416
1517 this . update ( ) ;
1618 this . tray . on ( "click" , ( ) => this . update ( ) ) ;
19+ this . tray . on ( "right-click" , ( ) => this . update ( ) ) ;
1720 }
1821
1922 update ( ) {
@@ -24,20 +27,32 @@ export class TrayManager {
2427 enabled : false
2528 } ,
2629 {
27- id : "connectInfo" ,
28- label : `Extension - ${ connected ? "Connected" : "Not connected" } ` ,
29- enabled : false
30+ type : "separator"
3031 } ,
3132 {
32- type : "separator"
33+ label : `Extension - ${ socketState ? socketState : "Connecting" } ` ,
34+ enabled : false
3335 } ,
3436 {
35- label : "Presence Store" ,
36- click : ( ) => shell . openExternal ( "https://premid.app/store" )
37+ label : `Discord - ${ discordState ? socketState : "Disconnected" } ` ,
38+ enabled : false
3739 } ,
3840 {
3941 type : "separator"
4042 } ,
43+ {
44+ label : "Auto launch" ,
45+ type : "checkbox" ,
46+ click : ( ) => {
47+ settings . get ( "autoLaunch" )
48+ ? settings . set ( "autoLaunch" , false )
49+ : settings . set ( "autoLaunch" , true ) ;
50+ updateAutoLaunch ( ) ;
51+ } ,
52+ checked : settings . get ( "autoLaunch" ) == true ,
53+ enabled : app . isPackaged ,
54+ visible : ! app . name . includes ( "Portable" )
55+ } ,
4156 {
4257 label : "Check for updates" ,
4358 click : ( ) => checkForUpdate ( ) ,
@@ -64,6 +79,13 @@ export class TrayManager {
6479 updateProcess &&
6580 updateProcess === "checking"
6681 } ,
82+ {
83+ type : "separator"
84+ } ,
85+ {
86+ label : "Presence Store" ,
87+ click : ( ) => shell . openExternal ( "https://premid.app/store" )
88+ } ,
6789 {
6890 label : "Acknowledgments" ,
6991 click : ( ) => shell . openExternal ( "https://premid.app/contributors" )
@@ -72,16 +94,10 @@ export class TrayManager {
7294 type : "separator"
7395 } ,
7496 {
75- label : `Quit ${ app . name } ` ,
97+ label : `Quit` ,
7698 role : "quit"
7799 }
78100 ] )
79101 ) ;
80102 }
81103}
82-
83- app . once ( "quit" , ( ) => {
84- if ( trayManager && trayManager . tray ) {
85- trayManager . tray . destroy ( ) ;
86- }
87- } ) ;
0 commit comments