@@ -19,7 +19,7 @@ const {
1919 REDUX_DEVTOOLS ,
2020} = require ( "electron-devtools-installer" ) ;
2121// Import Auto-Updater- Swell will update itself
22- // const { autoUpdater } = require("electron-updater");
22+ const { autoUpdater } = require ( "electron-updater" ) ;
2323// TouchBarButtons are our nav buttons(ex: Select All, Deselect All, Open Selected, Close Selected, Clear All)
2424const { TouchBarButton, TouchBarSpacer } = TouchBar ;
2525
@@ -41,7 +41,7 @@ const { createHttpLink } = require("apollo-link-http");
4141const { ApolloLink } = require ( "apollo-link" ) ;
4242
4343// proto-parser func for parsing .proto files
44- const protoParserFunc = require ( ' ./src/client/protoParser.js' ) ;
44+ const protoParserFunc = require ( " ./src/client/protoParser.js" ) ;
4545
4646// require menu file
4747require ( "./menu/mainMenu" ) ;
@@ -206,10 +206,10 @@ function createWindow() {
206206 webPreferences : {
207207 nodeIntegration : false ,
208208 contextIsolation : true ,
209- enableRemoteModule : false ,
209+ enableRemoteModule : false ,
210210 sandbox : true ,
211211 webSecurity : true ,
212- preload : path . resolve ( __dirname , ' preload.js' )
212+ preload : path . resolve ( __dirname , " preload.js" ) ,
213213 } ,
214214 icon : `${ __dirname } /src/assets/icons/64x64.png` ,
215215 } ) ;
@@ -280,8 +280,6 @@ function createWindow() {
280280 ************** EVENT LISTENERS **********
281281 ****************************************/
282282
283-
284-
285283// app.on('ready') will be called when Electron has finished
286284// initialization and is ready to create browser windows.
287285// Some APIs can only be used after this event occurs.
@@ -305,10 +303,13 @@ app.on("window-all-closed", () => {
305303 }
306304} ) ;
307305
308- ipcMain . on ( 'toMain' , ( e , args ) => {
309- console . log ( 'received from ipcRenderer inside main: ' , args ) ;
310- mainWindow . webContents . send ( 'fromMain' , `sending ${ args } back to ipcRenderer` ) ;
311- } )
306+ ipcMain . on ( "toMain" , ( e , args ) => {
307+ console . log ( "received from ipcRenderer inside main: " , args ) ;
308+ mainWindow . webContents . send (
309+ "fromMain" ,
310+ `sending ${ args } back to ipcRenderer`
311+ ) ;
312+ } ) ;
312313
313314// Auto Updating Functionality
314315const sendStatusToWindow = ( text ) => {
@@ -350,9 +351,9 @@ const sendStatusToWindow = (text) => {
350351// // You could call autoUpdater.quitAndInstall(); immediately
351352// autoUpdater.quitAndInstall();
352353// });
353- // ipcMain.on("quit-and-install", () => {
354- // autoUpdater.quitAndInstall();
355- // });
354+ ipcMain . on ( "quit-and-install" , ( ) => {
355+ autoUpdater . quitAndInstall ( ) ;
356+ } ) ;
356357// App page reloads when user selects "Refresh" from pop-up dialog
357358ipcMain . on ( "fatalError" , ( ) => {
358359 console . log ( "received fatal error" ) ;
@@ -471,50 +472,55 @@ ipcMain.on("import-collection", (event, args) => {
471472} ) ;
472473
473474// ============ CONFIRM CLEAR HISTORY / RESPONSE COMMUNICATION ===============
474- ipcMain . on ( ' confirm-clear-history' , ( event ) => {
475+ ipcMain . on ( " confirm-clear-history" , ( event ) => {
475476 const opts = {
476477 type : "warning" ,
477478 buttons : [ "Okay" , "Cancel" ] ,
478479 message : "Are you sure you want to clear history?" ,
479480 } ;
480481
481- dialog . showMessageBox ( null , opts )
482- . then ( ( response ) => {
483- console . log ( 'response to clear-history : ' , response )
484- mainWindow . webContents . send ( 'clear-history-response' , response )
485- } )
486- . catch ( err => console . log ( `Error on 'confirm-clear-history': ${ err } ` ) ) ;
482+ dialog
483+ . showMessageBox ( null , opts )
484+ . then ( ( response ) => {
485+ console . log ( "response to clear-history : " , response ) ;
486+ mainWindow . webContents . send ( "clear-history-response" , response ) ;
487+ } )
488+ . catch ( ( err ) => console . log ( `Error on 'confirm-clear-history': ${ err } ` ) ) ;
487489} ) ;
488490
489- ipcMain . on ( ' import-proto' , ( event ) => {
490- console . log ( ' import-proto event fired!!' )
491+ ipcMain . on ( " import-proto" , ( event ) => {
492+ console . log ( " import-proto event fired!!" ) ;
491493 let importedProto ;
492- dialog . showOpenDialog ( {
493- buttonLabel : "Import Proto File" ,
494- properties : [ 'openFile' , 'multiSelections' ] ,
495- filters : [ { name : 'Protos' , extensions : [ 'proto' ] } ]
496- } )
497- . then ( filePaths => {
498- if ( ! filePaths ) return undefined ;
499- // read uploaded proto file & save protoContent in the store
500- fs . readFile ( filePaths . filePaths [ 0 ] , 'utf-8' , ( err , file ) => {
501- // handle read error
502- if ( err ) {
503- return console . log ( 'error reading file : ' , err ) ;
504- } ;
505- importedProto = file ;
506- protoParserFunc ( importedProto )
507- . then ( protoObj => {
508- console . log ( 'finished with logic. about to send importedProto : ' , importedProto , ' and protoObj : ' , protoObj )
509- mainWindow . webContents . send ( 'proto-info' , importedProto , protoObj )
510- } )
494+ dialog
495+ . showOpenDialog ( {
496+ buttonLabel : "Import Proto File" ,
497+ properties : [ "openFile" , "multiSelections" ] ,
498+ filters : [ { name : "Protos" , extensions : [ "proto" ] } ] ,
499+ } )
500+ . then ( ( filePaths ) => {
501+ if ( ! filePaths ) return undefined ;
502+ // read uploaded proto file & save protoContent in the store
503+ fs . readFile ( filePaths . filePaths [ 0 ] , "utf-8" , ( err , file ) => {
504+ // handle read error
505+ if ( err ) {
506+ return console . log ( "error reading file : " , err ) ;
507+ }
508+ importedProto = file ;
509+ protoParserFunc ( importedProto ) . then ( ( protoObj ) => {
510+ console . log (
511+ "finished with logic. about to send importedProto : " ,
512+ importedProto ,
513+ " and protoObj : " ,
514+ protoObj
515+ ) ;
516+ mainWindow . webContents . send ( "proto-info" , importedProto , protoObj ) ;
517+ } ) ;
518+ } ) ;
519+ } )
520+ . catch ( ( err ) => {
521+ console . log ( err ) ;
511522 } ) ;
512- } )
513- . catch ( err => {
514- console . log ( err ) ;
515- } )
516-
517- } )
523+ } ) ;
518524
519525// ipcMain listener that
520526ipcMain . on ( "http1-fetch-message" , ( event , arg ) => {
0 commit comments