Skip to content

Commit

Permalink
Extracting reload method
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoarthur0 authored and thamara committed May 16, 2020
1 parent d673f75 commit 68c71dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions js/classes/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ class Calendar {
$('#calendar-table-body').html(this.generateTableBody());
}

reload() {
this.loadInternalStore();
this.loadInternalWaiveStore();
this.redraw();
}

redraw() {
this._draw();
}
Expand Down
6 changes: 2 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 68c71dc

Please sign in to comment.