1
0
Fork 0

Merge pull request #3157 from nxdefiant/master

calendar: Load holidays before events
master
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.15: Edit holidays on device in settings
0.16: Add menu to fast open settings to edit holidays 0.16: Add menu to fast open settings to edit holidays
Display Widgets in menus 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 = () => { 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 // 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 date = new Date(a.date);
const time = timeutils.decodeTime(a.t); const time = timeutils.decodeTime(a.t);
date.setHours(time.h); date.setHours(time.h);
date.setMinutes(time.m); date.setMinutes(time.m);
date.setSeconds(time.s); date.setSeconds(time.s);
return {date: date, msg: a.msg, type: "e"}; 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 = () => { const loadSettings = () => {
@ -280,14 +280,12 @@ const showMenu = function() {
setUI(); setUI();
}, },
/*LANG*/"Exit": () => load(), /*LANG*/"Exit": () => load(),
/*LANG*/"Settings": () => { /*LANG*/"Settings": () =>
const appSettings = eval(require('Storage').read('calendar.settings.js')); eval(require('Storage').read('calendar.settings.js'))(() => {
appSettings(() => {
loadSettings(); loadSettings();
loadEvents(); loadEvents();
showMenu(); showMenu();
}); }),
},
}; };
if (require("Storage").read("alarm.app.js")) { if (require("Storage").read("alarm.app.js")) {
menu[/*LANG*/"Launch Alarms"] = () => { menu[/*LANG*/"Launch Alarms"] = () => {

View File

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