File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ const appDataPath = app.getPath('userData');
88const optionsFile = `${ appDataPath } \\options.json` ;
99const db = new sqlite3 . Database ( `${ appDataPath } /database.db` ) ;
1010
11+ let isClockActive = false ;
12+
1113db . run ( `
1214 CREATE TABLE IF NOT EXISTS topics (
1315 id INTEGER PRIMARY KEY,
@@ -81,6 +83,14 @@ const createWindow = async () => {
8183 }
8284 } ) ;
8385
86+ mainWindow . on ( 'close' , ( event ) => {
87+ if ( isClockActive ) {
88+ event . preventDefault ( ) ;
89+ } else {
90+ app . quit ( ) ;
91+ }
92+ } ) ;
93+
8494 if ( ! fs . existsSync ( optionsFile ) ) {
8595 await saveOptions ( 'Daily' , 1 , 0 ) ;
8696 }
@@ -114,6 +124,10 @@ app.on('activate', () => {
114124 }
115125} ) ;
116126
127+ ipcMain . handle ( 'toggle-clock-active' , ( ) => {
128+ isClockActive = ! isClockActive ;
129+ } ) ;
130+
117131autoUpdater . on ( 'checking-for-update' , ( ) => {
118132 mainWindow . webContents . send ( 'auto-updater-callback' , 'Checking for Update' ) ;
119133} ) ;
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ contextBridge.exposeInMainWorld('api', {
1313 graphCompareHandler : ( data ) => ipcRenderer . invoke ( 'graph-compare-handler' , data ) ,
1414 optionsHandler : ( data ) => ipcRenderer . invoke ( 'options-handler' , data ) ,
1515 progressBarHandler : ( data ) => ipcRenderer . invoke ( 'progress-bar-handler' , data ) ,
16+
17+ toggleClockActive : ( ) => ipcRenderer . invoke ( 'toggle-clock-active' ) ,
1618} ) ;
1719
1820contextBridge . exposeInMainWorld ( 'autoUpdater' , {
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ function startTimer(){
4040 logStartTime = Date . now ( ) ;
4141 timerInterval = setInterval ( updateTimer , 10 ) ;
4242 toggleInputsDiv ( ) ;
43+ api . toggleClockActive ( ) ;
4344}
4445
4546async function stopTimer ( ) {
@@ -58,6 +59,7 @@ async function stopTimer(){
5859 await populateAnnualGraph ( 'All' ) ;
5960 await populateWeeklyCompareGraph ( 'All' ) ;
6061 await progressBar ( ) ;
62+ api . toggleClockActive ( ) ;
6163}
6264
6365function updateTimer ( ) {
You can’t perform that action at this time.
0 commit comments