From 18301fa7d71d7e76fa633b3f48d11a9f954f8c1c Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Mon, 11 Jan 2021 09:51:53 +1000 Subject: [PATCH] hark-store: cleanup dangling unreads Creates a noun poke %fix-dangling, which iterates through the unreads and dismiss those which refer to nodes which no longer exist. Additionally, adds a migration which runs this poke. --- pkg/arvo/app/hark-store.hoon | 60 +++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/pkg/arvo/app/hark-store.hoon b/pkg/arvo/app/hark-store.hoon index 031a20284..e048c4d4f 100644 --- a/pkg/arvo/app/hark-store.hoon +++ b/pkg/arvo/app/hark-store.hoon @@ -21,13 +21,13 @@ $% state:state-zero:store state:state-one:store state-2 + state-3 == +$ unread-stats [indices=(set index:graph-store) last=@da] :: -+$ state-2 - $: %2 - unreads-each=(jug stats-index:store index:graph-store) ++$ base-state + $: unreads-each=(jug stats-index:store index:graph-store) unreads-count=(map stats-index:store @ud) last-seen=(map stats-index:store @da) =notifications:store @@ -36,8 +36,14 @@ dnd=_| == :: ++$ state-2 + [%2 base-state] +:: ++$ state-3 + [%3 base-state] +:: +$ inflated-state - $: state-2 + $: state-3 cache == :: $cache: useful to have precalculated, but can be derived from state @@ -78,9 +84,16 @@ =| cards=(list card) |^ ?- -.old - %2 + %3 :- cards this(-.state old, +.state (inflate-cache:ha old)) + :: + %2 + %_ $ + -.old %3 + cards :_(cards [%pass / %agent [our dap]:bowl %poke noun+!>(%fix-dangling)]) + == + :: %1 %_ $ @@ -264,10 +277,43 @@ =^ cards state ?+ mark (on-poke:def mark vase) %hark-action (hark-action !<(action:store vase)) - %noun ~& +.state [~ state] + %noun (poke-noun !<(* vase)) == [cards this] :: + ++ poke-noun + |= val=* + ?+ val ~|(%bad-noun-poke !!) + %fix-dangling fix-dangling + %print ~&(+.state [~ state]) + == + :: + ++ fix-dangling + =/ graphs=(set resource) + get-keys:gra + :_ state + %+ roll + ~(tap by unreads-each) + |= $: [=stats-index:store indices=(set index:graph-store)] + out=(list card) + == + ?. ?=(%graph -.stats-index) out + ?. (~(has in graphs) graph.stats-index) + :_(out (poke-us %remove-graph graph.stats-index)) + %+ weld out + ^- (list card) + %+ turn + ^- (list index:graph-store) + %+ skip + `(list index:graph-store)`~(tap in indices) + |=(=index:graph-store (check-node-existence:gra graph.stats-index index)) + |=(=index:graph-store (poke-us %read-each stats-index index)) + :: + ++ poke-us + |= =action:store + ^- card + [%pass / %agent [our dap]:bowl %poke hark-action+!>(action)] + :: ++ hark-action |= =action:store ^- (quip card _state) @@ -636,7 +682,7 @@ == :: ++ inflate-cache - |= state-2 + |= state-3 ^+ +.state =/ nots=(list [p=@da =timebox:store]) (tap:orm notifications)