mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 05:22:27 +03:00
observe-hook: add new thread to leave graphs upon removing a group
This commit is contained in:
parent
6bb62d802b
commit
837abacb9c
@ -10,10 +10,13 @@
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
state-0
|
||||
==
|
||||
::
|
||||
+$ serial @uv
|
||||
+$ state-0 [%0 observers=(map serial observer:sur)]
|
||||
+$ state-1 [%1 observers=(map serial observer:sur)]
|
||||
::
|
||||
++ got-by-val
|
||||
|= [a=(map serial observer:sur) b=observer:sur]
|
||||
^- serial
|
||||
@ -24,7 +27,7 @@
|
||||
--
|
||||
::
|
||||
%- agent:dbug
|
||||
=| state-0
|
||||
=| state-1
|
||||
=* state -
|
||||
::
|
||||
^- agent:gall
|
||||
@ -35,8 +38,14 @@
|
||||
++ on-init
|
||||
|^ ^- (quip card _this)
|
||||
:_ this
|
||||
:_ ~
|
||||
(act /inv-gra [%watch %invite-store /invitatory/graph %invite-accepted-graph])
|
||||
:~ %+ act
|
||||
/inv-gra
|
||||
[%watch %invite-store /invitatory/graph %invite-accepted-graph]
|
||||
::
|
||||
%+ act
|
||||
/grp-gra
|
||||
[%watch %group-store /groups %group-leave-graph]
|
||||
==
|
||||
::
|
||||
++ act
|
||||
|= [=wire =action:sur]
|
||||
@ -56,7 +65,17 @@
|
||||
++ on-load
|
||||
|= old-vase=vase
|
||||
^- (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
|
||||
|= [=mark =vase]
|
||||
|
35
pkg/arvo/ted/group/leave-graph.hoon
Normal file
35
pkg/arvo/ted/group/leave-graph.hoon
Normal 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)
|
Loading…
Reference in New Issue
Block a user