From 064b9996e7e2bd01d7fdff608bb4ff30754ae9cc Mon Sep 17 00:00:00 2001 From: Gabriele Monaco Date: Sun, 5 Jun 2022 18:55:26 +0200 Subject: [PATCH] Added periodic call to forceCalendarSync --- apps/agenda/settings.js | 1 + apps/android/boot.js | 11 +++++++++++ apps/android/metadata.json | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/agenda/settings.js b/apps/agenda/settings.js index 7edb013b9..fe9dab2d8 100644 --- a/apps/agenda/settings.js +++ b/apps/agenda/settings.js @@ -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)); diff --git a/apps/android/boot.js b/apps/android/boot.js index 191db3838..a548089cb 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -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 }); diff --git a/apps/android/metadata.json b/apps/android/metadata.json index 7e4b275c5..27b77cf2f 100644 --- a/apps/android/metadata.json +++ b/apps/android/metadata.json @@ -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",