44 nativeTheme,
55 globalShortcut,
66 Menu,
7+ dialog,
78} = require ( 'electron/main' ) ;
89const { menubar } = require ( 'menubar' ) ;
910const { autoUpdater } = require ( 'electron-updater' ) ;
@@ -50,6 +51,12 @@ const contextMenu = Menu.buildFromTemplate([
5051 accelerator :
5152 process . platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I' ,
5253 } ,
54+ {
55+ label : 'Reset App' ,
56+ click : ( ) => {
57+ resetApp ( ) ;
58+ } ,
59+ } ,
5360 ] ,
5461 } ,
5562 { type : 'separator' } ,
@@ -62,17 +69,17 @@ const contextMenu = Menu.buildFromTemplate([
6269 } ,
6370] ) ;
6471
72+ const mb = menubar ( {
73+ icon : idleIcon ,
74+ index : `file://${ __dirname } /index.html` ,
75+ browserWindow : browserWindowOpts ,
76+ preloadWindow : true ,
77+ showDockIcon : false ,
78+ } ) ;
79+
6580app . whenReady ( ) . then ( async ( ) => {
6681 await onFirstRunMaybe ( ) ;
6782
68- const mb = menubar ( {
69- icon : idleIcon ,
70- index : `file://${ __dirname } /index.html` ,
71- browserWindow : browserWindowOpts ,
72- preloadWindow : true ,
73- showDockIcon : false ,
74- } ) ;
75-
7683 mb . on ( 'ready' , ( ) => {
7784 autoUpdater . checkForUpdatesAndNotify ( ) ;
7885
@@ -168,3 +175,24 @@ app.whenReady().then(async () => {
168175 app . setLoginItemSettings ( settings ) ;
169176 } ) ;
170177} ) ;
178+
179+ function resetApp ( ) {
180+ const cancelButtonId = 0 ;
181+
182+ const response = dialog . showMessageBoxSync ( mb . window , {
183+ type : 'warning' ,
184+ title : 'Reset Gitify' ,
185+ message :
186+ 'Are you sure you want to reset Gitify? You will be logged out of all accounts' ,
187+ buttons : [ 'Cancel' , 'Reset' ] ,
188+ defaultId : cancelButtonId ,
189+ cancelId : cancelButtonId ,
190+ } ) ;
191+
192+ if ( response === cancelButtonId ) {
193+ return ;
194+ }
195+
196+ mb . window . webContents . send ( 'gitify:reset-app' ) ;
197+ mb . app . quit ( ) ;
198+ }
0 commit comments