Skip to content

Commit

Permalink
Fix thamara#232: Total bar not updating on day change
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoarthur0 committed Jun 18, 2020
1 parent 757421b commit a9ea9be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions js/classes/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,17 @@ class Calendar {
this._draw();
}

/**
* Every day change this function is called to update the internal today variable if set to yesterday, and redraw.
* @param {int} oldDayDate
*/
refreshOnDayChange(oldDayDate) {
if (this._today.getDate() === oldDayDate) {
this._today = new Date();

This comment has been minimized.

Copy link
@tupaschoal

tupaschoal Jun 19, 2020

I'd just call goToCurrentDate, seems cleaner and the redraw is built-in in there

}
this.redraw();

This comment has been minimized.

Copy link
@tupaschoal

tupaschoal Jun 19, 2020

What do we gain from redrawing if the day doesn't change?

}

/*
* Display next month.
*/
Expand Down
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ function refreshOnDayChange() {
var today = new Date();
if (today > launchDate)
{
let oldDayDate = launchDate.getDate();
launchDate = today;
// Reload only the calendar itself to avoid a flash
win.webContents.executeJavaScript('calendar.redraw()');
win.webContents.executeJavaScript(`calendar.refreshOnDayChange(${oldDayDate})`);
}
}

Expand Down

0 comments on commit a9ea9be

Please sign in to comment.