From 68c71dc11e996d3d00b3a4df998ad04ec073a118 Mon Sep 17 00:00:00 2001 From: Arthur Araujo Date: Fri, 15 May 2020 23:10:04 -0300 Subject: [PATCH] Extracting reload method --- js/calendar.js | 2 +- js/classes/Calendar.js | 6 ++++++ main.js | 6 ++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/calendar.js b/js/calendar.js index 6cc2747a7..c6a6e688f 100644 --- a/js/calendar.js +++ b/js/calendar.js @@ -26,7 +26,7 @@ ipcRenderer.on('PREFERENCE_SAVED', function(event, inputs) { }); /* - * Get nofified when preferences has been updated. + * Get nofified when waivers get updated. */ ipcRenderer.on('WAIVER_SAVED', function() { calendar.loadInternalWaiveStore(); diff --git a/js/classes/Calendar.js b/js/classes/Calendar.js index 2f402147c..bc36c0c8b 100644 --- a/js/classes/Calendar.js +++ b/js/classes/Calendar.js @@ -367,6 +367,12 @@ class Calendar { $('#calendar-table-body').html(this.generateTableBody()); } + reload() { + this.loadInternalStore(); + this.loadInternalWaiveStore(); + this.redraw(); + } + redraw() { this._draw(); } diff --git a/main.js b/main.js index aebe6341b..ac6dd3b17 100644 --- a/main.js +++ b/main.js @@ -258,8 +258,7 @@ function createWindow() { const importResult = importDatabaseFromFile(response); if (importResult['result']) { // Reload only the calendar itself to avoid a flash - win.webContents.executeJavaScript('calendar.loadInternalStore()'); - win.webContents.executeJavaScript('calendar.redraw()'); + win.webContents.executeJavaScript('calendar.reload()'); dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { title: 'Time to Leave', @@ -304,8 +303,7 @@ function createWindow() { store.clear(); waivedWorkdays.clear(); // Reload only the calendar itself to avoid a flash - win.webContents.executeJavaScript('calendar.loadInternalStore()'); - win.webContents.executeJavaScript('calendar.redraw()'); + win.webContents.executeJavaScript('calendar.reload()'); dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { title: 'Time to Leave',