hark-graph-hook: autowatch unmanaged graphs

This commit is contained in:
Liam Fitzgerald 2020-12-07 13:55:55 +10:00
parent 30ee107762
commit f4c2dedba2
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 45 additions and 2 deletions

View File

@ -1,7 +1,7 @@
:: hark-graph-hook: notifications for graph-store [landscape]
::
/- store=hark-store, post, group-store, metadata-store, hook=hark-graph-hook
/+ resource, metadata, default-agent, dbug, graph-store, graph
/+ resource, metadata, default-agent, dbug, graph-store, graph, grouplib=group
::
::
~% %hark-graph-hook-top ..is ~
@ -49,6 +49,7 @@
ha ~(. +> bowl)
def ~(. (default-agent this %|) bowl)
met ~(. metadata bowl)
grp ~(. grouplib bowl)
gra ~(. graph bowl)
::
++ on-init
@ -161,8 +162,17 @@
++ add-graph
|= [rid=resource =graph:graph-store]
^- (quip card _state)
=/ group-rid=(unit resource)
(group-from-app-resource:met %graph rid)
?~ group-rid
~& no-group+rid
`state
=/ is-hidden=?
!(is-managed:grp u.group-rid)
=/ should-watch
|(is-hidden &(watch-on-self =(our.bowl entity.rid)))
:- ~
?. &(watch-on-self =(our.bowl entity.rid))
?. should-watch
state
state(watching (~(put in watching) [rid ~]))
::

View File

@ -22,6 +22,36 @@
?~ pax ~
?~ u.pax ~
`(de-path:resource n.u.pax)
::
++ wait-for-group-join
|= rid=resource
=/ m (strand ,~)
^- form:m
=/ pax
(en-path:resource rid)
|- ^- form:m
=* loop $
;< u-group=(unit group) bind:m
(scry:strandio ,(unit group) (weld /gx/group-store/groups (snoc pax %noun)))
?^ u-group
(pure:m ~)
;< ~ bind:m (sleep:strandio `@dr`(div ~s1 2))
loop
::
++ wait-for-md
|= rid=resource
=/ m (strand ,~)
^- form:m
=/ pax
(en-path:resource rid)
|- ^- form:m
=* loop $
;< groups=(set path) bind:m
(scry:strandio ,(set path) /gy/metadata-store/group-indices)
?: (~(has in groups) pax)
(pure:m ~)
;< ~ bind:m (sleep:strandio `@dr`(div ~s1 2))
loop
--
::
^- thread:spider
@ -50,11 +80,14 @@
;< ~ bind:m
%+ poke-our %group-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
;< ~ bind:m (wait-for-group-join rid.action)
::
;< ~ bind:m
%+ poke-our %metadata-hook
metadata-hook-action+!>([%add-synced ship.action (en-path:resource rid.action)])
::
;< ~ bind:m (wait-for-md rid.action)
::
;< ~ bind:m
%+ poke-our %graph-pull-hook
pull-hook-action+!>([%add ship.action rid.action])