aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-01-20 05:18:06 +0000
committerHolden Rohrer <hr@hrhr.dev>2020-01-20 00:31:03 -0500
commit70bbc86cdb2f5b98612966b226f7b3ac6be7e80c (patch)
treeb8f04a78be613c7d44949b1b1dde57c54f6796d7
parent34c860ef99fa155591a657512985553ac3a599fd (diff)
jarvis notif generation split out
On restoration of websocket, the notif actually gets pushed again, preventing pesky overwrites during downtime.
-rw-r--r--examples/jarvis.js11
1 files 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());
}