2021-01-13 07:50:37 +03:00
|
|
|
:: metadata-pull-hook [landscape]:
|
|
|
|
::
|
|
|
|
:: allow syncing group data from foreign paths to local paths
|
|
|
|
::
|
2021-02-03 05:18:38 +03:00
|
|
|
/- *group, invite-store, metadata=metadata-store, contact=contact-store
|
2021-01-13 07:50:37 +03:00
|
|
|
/+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook
|
2021-02-03 05:43:32 +03:00
|
|
|
/+ resource, mdl=metadata, agn=agentio
|
2021-01-13 07:50:37 +03:00
|
|
|
~% %group-hook-top ..part ~
|
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
++ config
|
|
|
|
^- config:pull-hook
|
|
|
|
:* %metadata-store
|
2021-01-28 09:13:57 +03:00
|
|
|
update:metadata
|
2021-01-13 07:50:37 +03:00
|
|
|
%metadata-update
|
|
|
|
%metadata-push-hook
|
2021-02-02 07:31:35 +03:00
|
|
|
%.n
|
2021-01-13 07:50:37 +03:00
|
|
|
==
|
2021-01-21 08:18:13 +03:00
|
|
|
+$ state-zero
|
2021-01-28 09:13:57 +03:00
|
|
|
[%0 previews=(map resource group-preview:metadata)]
|
2021-01-13 07:50:37 +03:00
|
|
|
::
|
|
|
|
--
|
|
|
|
::
|
|
|
|
::
|
|
|
|
%- agent:dbug
|
|
|
|
%+ verb |
|
|
|
|
^- agent:gall
|
|
|
|
%- (agent:pull-hook config)
|
|
|
|
^- (pull-hook:pull-hook config)
|
2021-01-21 08:18:13 +03:00
|
|
|
=| state-zero
|
|
|
|
=* state -
|
2021-01-22 07:12:09 +03:00
|
|
|
=> |_ =bowl:gall
|
|
|
|
++ def ~(. (default-agent state %|) bowl)
|
2021-02-03 05:18:38 +03:00
|
|
|
++ met ~(. mdl bowl)
|
2021-02-03 05:43:32 +03:00
|
|
|
++ io ~(. agn bowl)
|
2021-01-26 04:10:39 +03:00
|
|
|
++ get-preview
|
2021-01-22 07:12:09 +03:00
|
|
|
|= rid=resource
|
2021-01-26 03:09:31 +03:00
|
|
|
=/ =path
|
|
|
|
preview+(en-path:resource rid)
|
|
|
|
=/ =dock
|
|
|
|
[entity.rid %metadata-push-hook]
|
2021-02-03 05:43:32 +03:00
|
|
|
%+ ~(poke pass:io path) dock
|
|
|
|
metadata-hook-update+!>([%req-preview rid])
|
2021-01-22 07:12:09 +03:00
|
|
|
::
|
|
|
|
++ watch-invites
|
2021-02-03 05:43:32 +03:00
|
|
|
(~(watch-our pass:io /invites) %invite-store /updates)
|
2021-01-22 07:12:09 +03:00
|
|
|
::
|
|
|
|
++ take-invites
|
|
|
|
|= =sign:agent:gall
|
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.sign (on-agent:def /invites sign)
|
|
|
|
%fact
|
|
|
|
?> ?=(%invite-update p.cage.sign)
|
|
|
|
=+ !<(=update:invite-store q.cage.sign)
|
|
|
|
:_ state
|
|
|
|
?. ?=(%invite -.update) ~
|
2021-01-26 04:10:39 +03:00
|
|
|
(get-preview resource.invite.update)^~
|
2021-01-22 07:12:09 +03:00
|
|
|
::
|
|
|
|
%kick [watch-invites^~ state]
|
|
|
|
==
|
2021-02-03 05:18:38 +03:00
|
|
|
::
|
|
|
|
++ watch-contacts
|
2021-02-03 05:43:32 +03:00
|
|
|
(~(watch-our pass:io /contacts) %contact-store /all)
|
2021-02-03 05:18:38 +03:00
|
|
|
::
|
|
|
|
++ take-contacts
|
|
|
|
|= =sign:agent:gall
|
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.sign (on-agent:def /contacts sign)
|
|
|
|
%kick [~[watch-contacts] state]
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
:_ state
|
|
|
|
?> ?=(%contact-update p.cage.sign)
|
|
|
|
=+ !<(=update:contact q.cage.sign)
|
|
|
|
?+ -.update ~
|
|
|
|
%add
|
|
|
|
(check-contact contact.update)
|
|
|
|
::
|
|
|
|
%edit
|
|
|
|
?. ?=(%add-group -.edit-field.update) ~
|
|
|
|
%- add-missing-previews
|
|
|
|
(~(gas in *(set resource)) resource.edit-field.update ~)
|
|
|
|
::
|
|
|
|
%initial
|
|
|
|
^- (list card)
|
|
|
|
%- zing
|
|
|
|
%+ turn ~(tap by rolodex.update)
|
|
|
|
|=([ship =contact:contact] (check-contact contact))
|
|
|
|
==
|
|
|
|
==
|
2021-02-03 05:43:32 +03:00
|
|
|
::
|
2021-02-03 05:18:38 +03:00
|
|
|
++ check-contact
|
|
|
|
|= =contact:contact
|
|
|
|
^- (list card)
|
|
|
|
(add-missing-previews groups.contact)
|
|
|
|
::
|
|
|
|
++ add-missing-previews
|
|
|
|
|= groups=(set resource)
|
|
|
|
^- (list card)
|
|
|
|
=/ missing=(set resource)
|
|
|
|
(~(dif in ~(key by previews)) groups)
|
|
|
|
%+ murn ~(tap by missing)
|
|
|
|
|= group=resource
|
|
|
|
^- (unit card)
|
|
|
|
?^ (peek-metadatum:met %groups group) ~
|
|
|
|
`(get-preview group)
|
2021-02-03 05:43:32 +03:00
|
|
|
::
|
|
|
|
++ watch-store
|
|
|
|
(~(watch-our pass:io /store) %metadata-store /all)
|
|
|
|
::
|
|
|
|
++ take-store
|
|
|
|
|= =sign:agent:gall
|
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.sign (on-agent:def /store sign)
|
|
|
|
%kick [watch-store^~ state]
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?> ?=(%metadata-update p.cage.sign)
|
|
|
|
=+ !<(=update:metadata q.cage.sign)
|
|
|
|
?. ?=(%initial-group -.update) `state
|
|
|
|
`state(previews (~(del by previews) group.update))
|
|
|
|
==
|
2021-01-22 07:12:09 +03:00
|
|
|
--
|
2021-01-13 07:50:37 +03:00
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
dep ~(. (default:pull-hook this config) bowl)
|
2021-01-15 08:45:51 +03:00
|
|
|
met ~(. mdl bowl)
|
2021-01-22 07:12:09 +03:00
|
|
|
hc ~(. +> bowl)
|
2021-01-13 07:50:37 +03:00
|
|
|
::
|
|
|
|
++ on-init on-init:def
|
2021-01-21 08:18:13 +03:00
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= =vase
|
|
|
|
=+ !<(old=state-zero vase)
|
2021-01-26 03:09:25 +03:00
|
|
|
:_ this(state old)
|
2021-02-03 05:18:38 +03:00
|
|
|
%- zing
|
|
|
|
:~ ?: (~(has by wex.bowl) [/invites our.bowl %invite-store]) ~
|
|
|
|
~[watch-invites:hc]
|
|
|
|
?: (~(has by wex.bowl) [/contacts our.bowl %contact-store]) ~
|
|
|
|
~[watch-contacts:hc]
|
2021-02-03 05:43:32 +03:00
|
|
|
?: (~(has by wex.bowl) [/store our.bowl %metadata-store]) ~
|
|
|
|
~[watch-store:hc]
|
2021-02-03 05:18:38 +03:00
|
|
|
==
|
2021-01-21 08:18:13 +03:00
|
|
|
::
|
2021-01-26 04:10:39 +03:00
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
?. ?=(%metadata-hook-update mark)
|
|
|
|
(on-poke:def mark vase)
|
2021-01-28 09:13:57 +03:00
|
|
|
=+ !<(=hook-update:metadata vase)
|
|
|
|
?. ?=(%preview -.hook-update)
|
2021-01-26 04:10:39 +03:00
|
|
|
(on-poke:def mark vase)
|
2021-01-28 09:13:57 +03:00
|
|
|
:_ this(previews (~(put by previews) group.hook-update +.hook-update))
|
2021-02-03 05:43:32 +03:00
|
|
|
=/ =path
|
|
|
|
preview+(en-path:resource group.hook-update)
|
|
|
|
(fact-kick:io path mark^vase)
|
2021-01-26 04:10:39 +03:00
|
|
|
::
|
2021-01-15 08:45:51 +03:00
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
2021-01-22 07:12:09 +03:00
|
|
|
=^ cards state
|
|
|
|
?+ wire (on-agent:def:hc wire sign)
|
|
|
|
[%invites ~] (take-invites:hc sign)
|
2021-02-03 05:43:32 +03:00
|
|
|
[%contacts ~] (take-contacts:hc sign)
|
|
|
|
[%store ~] (take-store:hc sign)
|
2021-01-26 04:10:39 +03:00
|
|
|
::
|
|
|
|
[%preview @ @ @ ~]
|
|
|
|
?. ?=(%poke-ack -.sign)
|
|
|
|
(on-agent:def:hc wire sign)
|
|
|
|
:_ state
|
|
|
|
?~ p.sign ~
|
2021-02-03 05:43:32 +03:00
|
|
|
(fact-kick:io wire tang+!>(u.p.sign))
|
2021-01-18 03:58:03 +03:00
|
|
|
==
|
2021-01-22 07:12:09 +03:00
|
|
|
[cards this]
|
2021-01-15 08:45:51 +03:00
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
2021-01-18 03:58:03 +03:00
|
|
|
?> (team:title [our src]:bowl)
|
2021-01-15 08:45:51 +03:00
|
|
|
?. ?=([%preview @ @ @ ~] path)
|
|
|
|
(on-watch:def path)
|
|
|
|
=/ rid=resource
|
|
|
|
(de-path:resource t.path)
|
2021-01-28 09:13:57 +03:00
|
|
|
=/ prev=(unit group-preview:metadata)
|
2021-01-26 03:09:31 +03:00
|
|
|
(~(get by previews) rid)
|
2021-01-15 08:45:51 +03:00
|
|
|
:_ this
|
2021-01-26 04:10:39 +03:00
|
|
|
?~ prev
|
|
|
|
(get-preview rid)^~
|
2021-02-03 05:43:32 +03:00
|
|
|
(fact-init:io metadata-hook-update+!>([%preview u.prev]))^~
|
2021-01-15 08:45:51 +03:00
|
|
|
::
|
2021-01-13 07:50:37 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
2021-01-21 08:18:13 +03:00
|
|
|
++ on-arvo on-arvo:def
|
2021-01-18 03:58:03 +03:00
|
|
|
::
|
2021-01-13 07:50:37 +03:00
|
|
|
++ on-fail on-fail:def
|
2021-02-02 07:31:35 +03:00
|
|
|
++ resource-for-update resource-for-update:met
|
2021-01-13 07:50:37 +03:00
|
|
|
++ on-pull-nack
|
2021-01-26 03:09:25 +03:00
|
|
|
|= [=resource =tang]
|
2021-01-13 07:50:37 +03:00
|
|
|
^- (quip card _this)
|
2021-01-28 09:13:57 +03:00
|
|
|
=/ =associations:metadata
|
2021-01-26 03:09:25 +03:00
|
|
|
(metadata-for-group:met resource)
|
2021-01-15 08:45:51 +03:00
|
|
|
:_ this
|
|
|
|
%+ turn ~(tap by associations)
|
2021-01-28 09:13:57 +03:00
|
|
|
|= [=md-resource:metadata =association:metadata]
|
2021-02-03 05:43:32 +03:00
|
|
|
%+ poke-our:pass:io %metadata-store
|
2021-01-26 03:09:25 +03:00
|
|
|
:- %metadata-update
|
2021-01-28 09:13:57 +03:00
|
|
|
!> ^- update:metadata
|
2021-01-26 03:09:25 +03:00
|
|
|
[%remove resource md-resource]
|
2021-01-13 07:50:37 +03:00
|
|
|
::
|
|
|
|
++ on-pull-kick
|
2021-01-26 03:09:31 +03:00
|
|
|
|= =resource
|
2021-01-13 07:50:37 +03:00
|
|
|
^- (unit path)
|
|
|
|
`/
|
|
|
|
--
|