observe-hook: add new thread to leave graphs upon removing a group

This commit is contained in:
Logan Allen 2020-11-20 11:01:24 -06:00
parent 6bb62d802b
commit 837abacb9c
2 changed files with 58 additions and 4 deletions

View File

@ -10,10 +10,13 @@
+$ card card:agent:gall +$ card card:agent:gall
+$ versioned-state +$ versioned-state
$% state-0 $% state-0
state-0
== ==
:: ::
+$ serial @uv +$ serial @uv
+$ state-0 [%0 observers=(map serial observer:sur)] +$ state-0 [%0 observers=(map serial observer:sur)]
+$ state-1 [%1 observers=(map serial observer:sur)]
::
++ got-by-val ++ got-by-val
|= [a=(map serial observer:sur) b=observer:sur] |= [a=(map serial observer:sur) b=observer:sur]
^- serial ^- serial
@ -24,7 +27,7 @@
-- --
:: ::
%- agent:dbug %- agent:dbug
=| state-0 =| state-1
=* state - =* state -
:: ::
^- agent:gall ^- agent:gall
@ -35,8 +38,14 @@
++ on-init ++ on-init
|^ ^- (quip card _this) |^ ^- (quip card _this)
:_ this :_ this
:_ ~ :~ %+ act
(act /inv-gra [%watch %invite-store /invitatory/graph %invite-accepted-graph]) /inv-gra
[%watch %invite-store /invitatory/graph %invite-accepted-graph]
::
%+ act
/grp-gra
[%watch %group-store /groups %group-leave-graph]
==
:: ::
++ act ++ act
|= [=wire =action:sur] |= [=wire =action:sur]
@ -56,7 +65,17 @@
++ on-load ++ on-load
|= old-vase=vase |= old-vase=vase
^- (quip card _this) ^- (quip card _this)
`this(state !<(state-0 old-vase)) =/ old-state !<(versioned-state old-vase)
?- -.old-state
%1 `this(state old-state)
::
%0
=. this(state [%1 observers.old-state])
%+ on-poke
%observe-action
!> ^- action:sur
[%watch %group-store /groups %group-leave-graph]
==
:: ::
++ on-poke ++ on-poke
|= [=mark =vase] |= [=mark =vase]

View File

@ -0,0 +1,35 @@
/- spider, grp=group-store, gra=graph-store, met=metadata-store
/+ strandio, res=resource
::
=* strand strand:spider
=* poke-our poke-our:strandio
=* scry scry:strandio
::
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([=update:grp ~] arg)
?. ?=(%remove-group -.update)
(pure:m !>(~))
::
:: get graphs associated with group and archive them
=/ graphs=(list path)
%+ turn
%~ tap in
%~ key by
^- associations:met
%+ scry
%noun
(weld /group (en-path:res resource.update))
|= [g=group-path:met m=md-resource:met]
^- path
app-path.m
|-
?~ groups
(pure:m !>(~))
;< ~ bind:m
%+ poke-our %graph-store
!> ^- update:graph-store
[%archive-graph (de-path:res i.groups)]
$(groups t.groups)