garden: proper lag notifications w/ autodismiss

This commit is contained in:
Liam Fitzgerald 2021-09-09 13:04:14 +10:00
parent 39871d1036
commit f2e1e2fe93
2 changed files with 42 additions and 14 deletions

View File

@ -2,32 +2,34 @@
/+ verb, dbug, default-agent, agentio
|%
+$ card card:agent:gall
+$ state-0 [%0 lagging=_|]
::
::
++ lag-interval ~m10
--
=<
%+ verb &
%- agent:dbug
^- agent:gall
=| state-0
=* state -
=<
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
io ~(. agentio bowl)
pass pass:io
cc ~(. +> bowl)
++ on-init on-init:def
::
++ on-init
^- (quip card _this)
:_ this
[onboard watch:kiln check:lag ~]:cc
::
++ on-load
|= =vase
:_ this :: TODO: move to on-init
:- onboard:cc
(drop safe-watch:kiln:cc)
++ on-save !>(~)
=+ !<(old=state-0 vase)
`this(state old)
::
++ on-poke
|= [=mark =vase]
!!
++ on-save !>(state)
++ on-poke on-poke:def
++ on-peek on-peek:def
++ on-watch on-watch:def
++ on-agent
@ -59,13 +61,24 @@
==
--
::
++ on-arvo on-arvo:def
++ on-arvo
|= [=wire sign=sign-arvo]
^- (quip card _this)
?. ?=([%check-lag ~] wire) (on-arvo:def wire sign)
?> ?=([%behn %wake *] sign)
=+ .^(lag=? %$ (scry:io %$ /zen/lag))
?: =(lagging lag) :_(this ~[check:lag:cc])
:_ this(lagging lag)
:_ ~[check:lag:cc]
?:(lagging start:lag:cc stop:lag:cc)
::
++ on-fail on-fail:def
++ on-leave on-leave:def
--
|_ =bowl:gall
+* io ~(. agentio bowl)
pass pass:io
::
++ onboard
^- card
%- poke:ha
@ -73,7 +86,15 @@
:: We special case this in the grid UI, but should include something
:: for third parties
[~[text+'Welcome to urbit'] ~ now.bowl / /]
::
++ lag
|%
++ check (~(wait pass /check-lag) (add now.bowl lag-interval))
++ place [q.byk.bowl /lag]
++ body `body:hark`[~[text/'Runtime lagging'] ~ now.bowl / /]
++ start (poke:ha %add-note [/ place] body)
++ stop (poke:ha %del-place place)
--
++ ha
|%
++ pass ~(. ^pass /hark)

View File

@ -24,9 +24,16 @@
%all-stats (all-stats +.upd)
::%read-note (index +.upd)
::%note-read (note-read +.upd)
:: %archive (notif-ref +.upd)
%archive (archive +.upd)
==
::
++ archive
|= [t=(unit @da) b=^bin]
%- pairs
:~ time+?~(t ~ s+(scot %ud u.t))
bin+(bin b)
==
::
++ note-read
|= *
(pairs ~)