Added periodic call to forceCalendarSync

pull/1884/head
Gabriele Monaco 2022-06-05 18:55:26 +02:00
parent 9e4d58d215
commit 064b9996e7
3 changed files with 13 additions and 1 deletions

View File

@ -17,6 +17,7 @@
case 1:
require("Storage").writeJSON("android.calendar.json",[]);
CALENDAR = [];
/* falls through */
case 2:
gbSend({t:"force_calendar_sync", ids: CALENDAR.map(e=>e.id)});
E.showAlert(/*LANG*/"Request sent to the phone").then(()=>E.showMenu(mainmenu));

View File

@ -125,6 +125,17 @@
if (!settings.keep)
NRF.on("disconnect", () => require("messages").clearAll()); // remove all messages on disconnect
setInterval(sendBattery, 10*60*1000);
// Fix calendar every 2 days (can be done manually too)
function forceCalendarSync() {
if(NRF.getSecurityStatus().connected) {
var cal = require("Storage").readJSON("android.calendar.json",true);
if (!cal || !Array.isArray(cal)) cal = [];
gbSend({t:"force_calendar_sync", ids: cal.map(e=>e.id)});
setTimeout(forceCalendarSync, 2*24*60*60*1000);
} else
NRF.once("connect", () => setTimeout(forceCalendarSync, 4000));
}
setTimeout(forceCalendarSync, 2*24*60*60*1000); //schedule the first
// Health tracking
Bangle.on('health', health=>{
gbSend({ t: "act", stp: health.steps, hrm: health.bpm });

View File

@ -2,7 +2,7 @@
"id": "android",
"name": "Android Integration",
"shortName": "Android",
"version": "4.02",
"version": "0.11",
"description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.",
"icon": "app.png",
"tags": "tool,system,messages,notifications,gadgetbridge",