Merge pull request #3157 from nxdefiant/master

calendar: Load holidays before events
pull/3159/head
Rob Pilling 2024-01-15 21:01:07 +00:00 committed by GitHub
commit c7cddf7a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 17 deletions

View File

@ -17,3 +17,4 @@
0.15: Edit holidays on device in settings
0.16: Add menu to fast open settings to edit holidays
Display Widgets in menus
0.17: Load holidays before events so the latter is not overpainted

View File

@ -43,24 +43,24 @@ const dowLbls = function() {
}();
const loadEvents = () => {
// add holidays & other events
events = (require("Storage").readJSON("calendar.days.json",1) || []).map(d => {
const date = new Date(d.date);
const o = {date: date, msg: d.name, type: d.type};
if (d.repeat) {
o.repeat = d.repeat;
}
return o;
});
// all alarms that run on a specific date
events = (require("Storage").readJSON("sched.json",1) || []).filter(a => a.on && a.date).map(a => {
events = events.concat((require("Storage").readJSON("sched.json",1) || []).filter(a => a.on && a.date).map(a => {
const date = new Date(a.date);
const time = timeutils.decodeTime(a.t);
date.setHours(time.h);
date.setMinutes(time.m);
date.setSeconds(time.s);
return {date: date, msg: a.msg, type: "e"};
});
// add holidays & other events
(require("Storage").readJSON("calendar.days.json",1) || []).forEach(d => {
const date = new Date(d.date);
const o = {date: date, msg: d.name, type: d.type};
if (d.repeat) {
o.repeat = d.repeat;
}
events.push(o);
});
}));
};
const loadSettings = () => {
@ -280,14 +280,12 @@ const showMenu = function() {
setUI();
},
/*LANG*/"Exit": () => load(),
/*LANG*/"Settings": () => {
const appSettings = eval(require('Storage').read('calendar.settings.js'));
appSettings(() => {
/*LANG*/"Settings": () =>
eval(require('Storage').read('calendar.settings.js'))(() => {
loadSettings();
loadEvents();
showMenu();
});
},
}),
};
if (require("Storage").read("alarm.app.js")) {
menu[/*LANG*/"Launch Alarms"] = () => {

View File

@ -1,7 +1,7 @@
{
"id": "calendar",
"name": "Calendar",
"version": "0.16",
"version": "0.17",
"description": "Monthly calendar, displays holidays uploaded from the web interface and scheduled events.",
"icon": "calendar.png",
"screenshots": [{"url":"screenshot_calendar.png"}],