mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
Add possibility to fetch calendars through socket notifications
This commit is contained in:
parent
2d15e4f976
commit
8bf9b9bef9
@ -133,6 +133,10 @@ Module.register("calendar", {
|
|||||||
|
|
||||||
// Override socket notification handler.
|
// Override socket notification handler.
|
||||||
socketNotificationReceived: function (notification, payload) {
|
socketNotificationReceived: function (notification, payload) {
|
||||||
|
if (notification === "FETCH_CALENDAR") {
|
||||||
|
this.sendSocketNotification(notification, {"url": payload.url, "id": this.identifier})
|
||||||
|
}
|
||||||
|
|
||||||
if (this.identifier !== payload.id) {
|
if (this.identifier !== payload.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,14 @@ module.exports = NodeHelper.create({
|
|||||||
socketNotificationReceived: function (notification, payload) {
|
socketNotificationReceived: function (notification, payload) {
|
||||||
if (notification === "ADD_CALENDAR") {
|
if (notification === "ADD_CALENDAR") {
|
||||||
this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.selfSignedCert, payload.id);
|
this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth, payload.broadcastPastEvents, payload.selfSignedCert, payload.id);
|
||||||
|
} else if (notification === "FETCH_CALENDAR") {
|
||||||
|
key = payload.id + payload.url;
|
||||||
|
if (typeof this.fetchers[key] === "undefined") {
|
||||||
|
Log.error("Calendar Error. No fetcher exists with key: ", key);
|
||||||
|
this.sendSocketNotification("CALENDAR_ERROR", { error_type: "MODULE_ERROR_UNSPECIFIED" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.fetchers[key].startFetch();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user