urbit/pkg/arvo/app/group-hook.hoon

109 lines
2.0 KiB
Plaintext
Raw Normal View History

2019-11-21 02:37:43 +03:00
:: group-hook: allow syncing group data from foreign paths to local paths
::
2020-05-21 07:30:02 +03:00
/- *group, hook=group-hook, *invite-store
2020-06-24 03:28:57 +03:00
/+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook, push-hook, resource
~% %group-hook-top ..is ~
2019-11-21 02:37:43 +03:00
|%
+$ card card:agent:gall
::
++ versioned-state
$% state-zero
2020-05-15 01:50:04 +03:00
state-one
2019-11-21 02:37:43 +03:00
==
::
::
+$ state-zero
$: %0
synced=(map path ship)
==
::
2020-05-15 01:50:04 +03:00
+$ state-one
$: %1
2020-06-24 03:28:57 +03:00
~
2020-05-15 01:50:04 +03:00
==
::
2019-11-21 02:37:43 +03:00
--
::
2020-05-15 01:50:04 +03:00
=| state-one
2019-11-21 02:37:43 +03:00
=* state -
::
%- agent:dbug
%+ verb |
2019-11-21 02:37:43 +03:00
^- agent:gall
2020-06-24 03:28:57 +03:00
|_ =bowl:gall
+* this .
group-core +>
gc ~(. group-core bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
:: ^- (quip card _this)
:: :_ this
:: ~[watch-store:gc]
++ on-save !>(state)
++ on-load
|= =vase
^- (quip card _this)
=/ old !<(versioned-state vase)
?- -.old
%1 [~ this(state old)]
%0
:_ this(state *state-one)
|^
%+ turn
~(tap by synced.old)
|= [=path host=ship]
^- card
?> ?=([@ @ *] path)
=/ pax=^path
?: =('~' i.path)
t.path
path
=/ rid=resource
?> ?=([@ @ *] pax)
=/ ship
(slav %p i.pax)
[ship i.t.pax]
?: =(our.bowl host)
(add-push rid)
(add-pull rid host)
::
++ poke-our
|= [app=term =cage]
^- card
[%pass / %agent [our.bowl app] %poke cage]
++ add-pull
|= [rid=resource host=ship]
^- card
%+ poke-our
%group-pull-hook
:- %pull-hook-action
!> ^- action:pull-hook
[%add host rid]
::
++ add-push
|= rid=resource
^- card
%+ poke-our
%group-push-hook
:- %push-hook-action
!> ^- action:push-hook
[%add rid]
--
2020-06-02 09:24:37 +03:00
2020-05-19 23:53:55 +03:00
==
2020-06-24 03:28:57 +03:00
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-poke on-poke:def
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-agent on-agent:def
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-watch on-watch:def
2020-05-21 07:30:02 +03:00
::
2020-06-24 03:28:57 +03:00
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-arvo on-arvo:def
++ on-fail on-fail:def
2019-11-21 02:37:43 +03:00
--