metadata-pull-hook: watch contacts for new preview

Fetch metadata previews when we learn of a group via a contact's pinned
groups.
This commit is contained in:
Liam Fitzgerald 2021-02-03 12:18:38 +10:00
parent 4e89ad4b13
commit d8dc792497
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -2,7 +2,7 @@
:: ::
:: allow syncing group data from foreign paths to local paths :: allow syncing group data from foreign paths to local paths
:: ::
/- *group, invite-store, metadata=metadata-store /- *group, invite-store, metadata=metadata-store, contact=contact-store
/+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook /+ default-agent, verb, dbug, store=group-store, grpl=group, pull-hook
/+ resource, mdl=metadata /+ resource, mdl=metadata
~% %group-hook-top ..part ~ ~% %group-hook-top ..part ~
@ -31,6 +31,7 @@
=* state - =* state -
=> |_ =bowl:gall => |_ =bowl:gall
++ def ~(. (default-agent state %|) bowl) ++ def ~(. (default-agent state %|) bowl)
++ met ~(. mdl bowl)
++ get-preview ++ get-preview
|= rid=resource |= rid=resource
^- card ^- card
@ -59,6 +60,52 @@
:: ::
%kick [watch-invites^~ state] %kick [watch-invites^~ state]
== ==
::
++ watch-contacts
^- card
[%pass /contacts %agent [our.bowl %contact-store] %watch /all]
::
++ 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))
==
==
++ 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)
-- --
|_ =bowl:gall |_ =bowl:gall
+* this . +* this .
@ -73,8 +120,12 @@
|= =vase |= =vase
=+ !<(old=state-zero vase) =+ !<(old=state-zero vase)
:_ this(state old) :_ this(state old)
?: (~(has by wex.bowl) [/invites our.bowl %invite-store]) ~ %- zing
~[watch-invites:hc] :~ ?: (~(has by wex.bowl) [/invites our.bowl %invite-store]) ~
~[watch-invites:hc]
?: (~(has by wex.bowl) [/contacts our.bowl %contact-store]) ~
~[watch-contacts:hc]
==
:: ::
++ on-poke ++ on-poke
|= [=mark =vase] |= [=mark =vase]
@ -95,6 +146,7 @@
=^ cards state =^ cards state
?+ wire (on-agent:def:hc wire sign) ?+ wire (on-agent:def:hc wire sign)
[%invites ~] (take-invites:hc sign) [%invites ~] (take-invites:hc sign)
[%contacts ~] (take-invites:hc sign)
:: ::
[%preview @ @ @ ~] [%preview @ @ @ ~]
?. ?=(%poke-ack -.sign) ?. ?=(%poke-ack -.sign)