Skip to content

Commit

Permalink
Merge pull request #525 from Peergos/fix/day-check-bug
Browse files Browse the repository at this point in the history
fix periodic day check
  • Loading branch information
ianopolous authored Sep 19, 2023
2 parents 21474ca + e5d2524 commit b3720b8
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions assets/apps/calendar/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var mainWindow;
var origin;
var theme;
var hasEmail;
var canRefreshDay = false;
let handler = function (e) {
// You must verify that the origin of the message's sender matches your
// expectations. In this case, we're only planning on accepting messages
Expand Down Expand Up @@ -100,19 +99,14 @@ calendarSettingsButton.onclick=function(e) {
toggleCalendarsView(e);
};
function startCurrentDayCheck() {
let repeatMS = 1000*60*10;
if (canRefreshDay) {
let today = moment();
let sameDay = today.day() == currentMoment.day();
if (sameDay) {
setTimeout(() => startCurrentDayCheck(), repeatMS);
} else {
currentMoment = today;
if(!reload(today)) {
setTimeout(() => startCurrentDayCheck(), repeatMS);
}
}
let repeatMS = 1000*60*10; //10 mins
let today = moment();
let calDate = moment(cal.getDate().getTime());
let sameDay = today.day() == calDate.day();
if (!sameDay) {
updateCalendar('move-today');
}
setTimeout(() => startCurrentDayCheck(), repeatMS);
}


Expand Down Expand Up @@ -491,10 +485,6 @@ function removeRecurringScheduleInstances(parentId) {
});
}
function disableToolbarButtons(newValue){
canRefreshDay = !newValue;
if (canRefreshDay) {
startCurrentDayCheck();
}
let calendarSettings = document.getElementById("calendar-settings");
calendarSettings.disabled = newValue;
let calendarType = document.getElementById("dropdownMenu-calendarType");
Expand Down Expand Up @@ -601,6 +591,7 @@ function initialiseCalendar(loadCalendarAsGuest, calendars) {
setDropdownCalendarType();
setEventListener();
disableToolbarButtons(true);
startCurrentDayCheck();
}
function ScheduleInfo() {
this.id = null;
Expand Down Expand Up @@ -1802,7 +1793,9 @@ function onClickMenu(e) {
}

function onClickNavi(e) {
var action = getDataAction(e.target);
updateCalendar(getDataAction(e.target));
}
function updateCalendar(action) {
let viewName = cal.getViewName();
let wasMoment = currentMoment.clone();
if (action == 'move-today') {
Expand Down

0 comments on commit b3720b8

Please sign in to comment.