pull-hook: add +take-update arm

This commit is contained in:
Liam Fitzgerald 2021-01-25 13:07:47 +10:00
parent 4cb8339bf1
commit 2ce654555c
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
4 changed files with 30 additions and 37 deletions

View File

@ -48,4 +48,6 @@
=/ maybe-time (peek-update-log:gra resource)
?~ maybe-time `/
`/(scot %da u.maybe-time)
::
++ take-update take-update:dep
--

View File

@ -49,4 +49,6 @@
|= =resource
^- (unit path)
`/
::
++ take-update take-update:dep
--

View File

@ -17,7 +17,7 @@
%metadata-push-hook
==
+$ state-zero
[%0 previews=(map resource group-preview)]
[%0 ~]
::
--
::
@ -31,14 +31,11 @@
=* state -
=> |_ =bowl:gall
++ def ~(. (default-agent state %|) bowl)
++ watch-preview
++ add-resource
|= rid=resource
^- card
=/ =path
preview+(en-path:resource rid)
=/ =dock
[entity.rid %metadata-push-hook]
[%pass path %agent dock %watch path]
=- [%pass / %agent [our dap]:bowl %poke -]
pull-hook-action+!>(`action:pull-hook`[%add [entity .]:rid])
::
++ watch-invites
^- card
@ -54,40 +51,17 @@
:_ state
?. ?=(%invite -.update) ~
?. =(%contacts term.update) ~
(watch-preview resource.invite.update)^~
(add-resource resource.invite.update)^~
::
%kick [watch-invites^~ state]
==
::
++ take-preview
|= [=wire =sign:agent:gall]
^- (quip card _state)
?> ?=([%preview @ *] wire)
=/ rid=resource
(de-path:resource t.wire)
?+ -.sign (on-agent:def wire sign)
%fact
?> =(%metadata-update p.cage.sign)
=+ !<(upd=metadata-update q.cage.sign)
?> ?=(%preview -.upd)
:_ state(previews (~(put by previews) rid +.upd))
:~ [%give %fact ~[wire] cage.sign]
[%give %kick ~[wire] ~]
==
::
%watch-ack
:_ state
?~ p.sign ~
:~ [%give %fact ~[wire] tang+!>(u.p.sign)]
[%give %kick ~[wire] ~]
==
==
--
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
dep ~(. (default:pull-hook this config) bowl)
met ~(. mdl bowl)
grp ~(. grpl bowl)
hc ~(. +> bowl)
::
++ on-init on-init:def
@ -106,7 +80,6 @@
=^ cards state
?+ wire (on-agent:def:hc wire sign)
[%invites ~] (take-invites:hc sign)
[%preview @ @ @ ~] (take-preview:hc wire sign)
==
[cards this]
::
@ -117,8 +90,7 @@
(on-watch:def path)
=/ rid=resource
(de-path:resource t.path)
=/ prev=(unit group-preview)
(~(get by previews) rid)
=/ prev=(unit group-preview) ~
:_ this
?^ prev
:~ [%give %fact ~ metadata-update+!>([%preview u.prev])]
@ -147,7 +119,12 @@
[%remove resource md-resource]
::
++ on-pull-kick
|= =resource
|= rid=resource
^- (unit path)
?. (is-member:grp our.bowl rid) ~
`/
::
++ take-update
|= [rid=resource =vase]
`this
--

View File

@ -76,6 +76,10 @@
%- (slog tank tang)
[~ pull-hook]
::
++ take-update
|= [=resource =vase]
`pull-hook
::
++ on-pull-kick
|= =resource
*(unit path)
@ -106,6 +110,12 @@
++ on-pull-kick
|~ resource
*(unit path)
:: +take-update: process store update
::
:: Perform actions before the store receives the update
++ take-update
|~ [resource vase]
*[(list card) _^|(..on-init)]
::
:: from agent:gall
++ on-init
@ -292,8 +302,10 @@
=^ cards pull-hook
(on-agent:og wire sign)
[cards this]
=^ cards pull-hook
(take-update:og rid q.cage.sign)
:_ this
~[(update-store:hc rid q.cage.sign)]
(snoc cards (update-store:hc rid q.cage.sign))
==
++ on-leave
|= =path