Fetch grid on load

This commit is contained in:
Tanner Collin 2023-06-05 19:16:29 -06:00
parent c5b9343c9a
commit f15fd9cf20

View File

@ -58,16 +58,6 @@ Graphics.prototype.setFontAnton = function(scale) {
});
}
if (Bangle.http && !grid){
Bangle.http("https://api.home.dns.t0.vc/grid", {timeout:3000}).then(event => {
grid = JSON.parse(event.resp);
//console.log(grid);
}).catch((e)=>{
myMessage = "GET error";
if (paintFace) paintFace();
});
}
// queue next draw
if (drawTimer) clearTimeout(drawTimer);
drawTimer = setTimeout(function() {
@ -168,10 +158,13 @@ Graphics.prototype.setFontAnton = function(scale) {
}, 2000);
if (gridNum >= 0 && grid[gridNum]) {
myMessage = grid[gridNum];
if (paintFace) paintFace();
if (Bangle.http){
const options = {timeout:3000, method: "post", body: gridNum};
Bangle.http("https://api.home.dns.t0.vc/grid", options).then(event => {
myMessage = grid[gridNum];
myMessage = "ok"
if (paintFace) paintFace();
}).catch((e)=>{
myMessage = "POST error";
@ -187,6 +180,16 @@ Graphics.prototype.setFontAnton = function(scale) {
}
};
if (Bangle.http){
Bangle.http("https://api.home.dns.t0.vc/grid", {timeout:3000}).then(event => {
grid = JSON.parse(event.resp);
//console.log(grid);
}).catch((e)=>{
myMessage = "GET error";
if (paintFace) paintFace();
});
}
Bangle.on('swipe', handleSwipe);
Bangle.on('drag', handleDrag);