From 70bbc86cdb2f5b98612966b226f7b3ac6be7e80c Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Mon, 20 Jan 2020 05:18:06 +0000
Subject: jarvis notif generation split out
On restoration of websocket, the notif actually gets pushed again, preventing pesky overwrites during downtime.
---
examples/jarvis.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/examples/jarvis.js b/examples/jarvis.js
index 9b692e2..3e18e85 100644
--- a/examples/jarvis.js
+++ b/examples/jarvis.js
@@ -24,6 +24,7 @@ var sender;
function init(send){
sender = send; // tileUpdates require knowledge of the sender
setTimeout(()=>{writes.enable()},1000); // Would fail if a write were added because it would be within a second of cursor send
+ writes.enqueue(genNotif().towrite());
}
function deinit(){
@@ -63,16 +64,22 @@ notifsrc = notifsrc.replace('COMMAND', command).replace('SIGNATURE', sig);
var minsUp = 0;
var callct = 0;
var ctrl;
-function notifRefresh(){
+
+function genNotif(){
let newnotif = new Space();
newnotif.loc = [-6, 20];
text = notifsrc;
text = text.replace('UPTIME', Math.floor(minsUp/60) + 'h' + minsUp%60 + 'm');
text = text.replace('JARVIS', callct);
newnotif.adhoc(text);
+ return newnotif
+}
+
+function notifRefresh(){
+ let newnotif = genNotif();
let diff = newnotif.copy();
if (typeof notif !== 'undefined') diff.comb(notif, comb.sub);
- notif = newnotif;
+ notif = diff;
ctrl = ms(notif);
return (diff.towrite());
}
--
cgit