2020-09-01 04:54:39 +03:00
|
|
|
:: contact-hook [landscape]
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
2020-05-25 08:52:54 +03:00
|
|
|
/- group-hook,
|
2020-03-02 02:35:44 +03:00
|
|
|
*contact-hook,
|
2020-05-29 04:53:14 +03:00
|
|
|
*contact-view,
|
2020-10-22 20:17:15 +03:00
|
|
|
inv=invite-store,
|
2020-03-02 02:35:44 +03:00
|
|
|
*metadata-hook,
|
2020-05-25 08:52:54 +03:00
|
|
|
*metadata-store,
|
|
|
|
*group
|
2020-12-02 10:03:05 +03:00
|
|
|
/+ *contact-json,
|
|
|
|
default-agent,
|
|
|
|
dbug,
|
|
|
|
group-store,
|
|
|
|
verb,
|
|
|
|
resource,
|
|
|
|
grpl=group,
|
|
|
|
*migrate
|
2020-04-03 00:49:46 +03:00
|
|
|
~% %contact-hook-top ..is ~
|
2019-12-14 02:22:36 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
+$ versioned-state
|
|
|
|
$% state-zero
|
2020-03-13 22:32:28 +03:00
|
|
|
state-one
|
2020-07-17 04:21:30 +03:00
|
|
|
state-two
|
2020-07-23 10:42:41 +03:00
|
|
|
state-three
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
2020-03-13 22:32:28 +03:00
|
|
|
+$ state-zero [%0 state-base]
|
|
|
|
+$ state-one [%1 state-base]
|
2020-07-17 04:21:30 +03:00
|
|
|
+$ state-two [%2 state-base]
|
2020-07-23 10:42:41 +03:00
|
|
|
+$ state-three [%3 state-base]
|
2020-03-13 22:32:28 +03:00
|
|
|
+$ state-base
|
2020-04-21 21:58:37 +03:00
|
|
|
$: =synced
|
2019-12-14 02:22:36 +03:00
|
|
|
invite-created=_|
|
|
|
|
==
|
|
|
|
--
|
2020-07-23 10:42:41 +03:00
|
|
|
=| state-three
|
2019-12-14 02:22:36 +03:00
|
|
|
=* state -
|
2020-03-12 03:33:48 +03:00
|
|
|
%- agent:dbug
|
2020-05-25 08:52:54 +03:00
|
|
|
%+ verb |
|
2019-12-14 02:22:36 +03:00
|
|
|
^- agent:gall
|
|
|
|
=<
|
|
|
|
|_ bol=bowl:gall
|
|
|
|
+* this .
|
|
|
|
contact-core +>
|
|
|
|
cc ~(. contact-core bol)
|
|
|
|
def ~(. (default-agent this %|) bol)
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
|
|
|
:_ this(invite-created %.y)
|
2020-10-21 01:18:30 +03:00
|
|
|
:~ (invite-poke:cc [%create %contacts])
|
2019-12-14 02:22:36 +03:00
|
|
|
[%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]
|
2020-06-24 03:28:57 +03:00
|
|
|
[%pass /group %agent [our.bol %group-store] %watch /groups]
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
2020-03-13 22:32:28 +03:00
|
|
|
|= old-vase=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
=/ old !<(versioned-state old-vase)
|
2020-07-17 04:21:30 +03:00
|
|
|
=| cards=(list card)
|
|
|
|
|^
|
2020-09-01 04:54:39 +03:00
|
|
|
|- ^- (quip card _this)
|
2020-07-23 10:42:41 +03:00
|
|
|
?: ?=(%3 -.old)
|
2020-07-17 04:21:30 +03:00
|
|
|
[cards this(state old)]
|
2020-07-23 10:42:41 +03:00
|
|
|
?: ?=(%2 -.old)
|
|
|
|
%_ $
|
|
|
|
old [%3 +.old]
|
|
|
|
::
|
|
|
|
cards
|
|
|
|
%+ welp
|
|
|
|
cards
|
|
|
|
%- zing
|
|
|
|
%+ turn
|
|
|
|
~(tap by synced.old)
|
|
|
|
|= [=path =ship]
|
|
|
|
^- (list card)
|
|
|
|
?. =(ship our.bol)
|
|
|
|
~
|
|
|
|
?> ?=([%ship *] path)
|
|
|
|
:~ (pass-store contacts+t.path %leave ~)
|
|
|
|
(pass-store contacts+path %watch contacts+path)
|
|
|
|
==
|
|
|
|
==
|
2020-03-13 22:32:28 +03:00
|
|
|
?: ?=(%1 -.old)
|
2020-07-17 04:21:30 +03:00
|
|
|
%_ $
|
|
|
|
-.old %2
|
|
|
|
::
|
2020-09-01 04:54:39 +03:00
|
|
|
synced.old
|
2020-07-17 04:21:30 +03:00
|
|
|
%- malt
|
|
|
|
%+ turn
|
|
|
|
~(tap by synced.old)
|
|
|
|
|= [=path =ship]
|
|
|
|
[ship+path ship]
|
|
|
|
::
|
|
|
|
cards
|
|
|
|
^- (list card)
|
2020-07-22 15:54:34 +03:00
|
|
|
;: welp
|
2020-07-17 04:21:30 +03:00
|
|
|
:~ [%pass /group %agent [our.bol %group-store] %leave ~]
|
|
|
|
[%pass /group %agent [our.bol %group-store] %watch /groups]
|
|
|
|
==
|
2020-07-22 15:54:34 +03:00
|
|
|
kick-old-subs
|
|
|
|
cards
|
|
|
|
==
|
2020-03-13 22:32:28 +03:00
|
|
|
==
|
2020-07-17 04:21:30 +03:00
|
|
|
%_ $
|
|
|
|
-.old %1
|
|
|
|
::
|
|
|
|
cards
|
|
|
|
:_ cards
|
|
|
|
[%pass /group %agent [our.bol %group-store] %watch /updates]
|
|
|
|
==
|
|
|
|
++ kick-old-subs
|
|
|
|
=/ paths
|
|
|
|
%+ turn
|
|
|
|
~(val by sup.bol)
|
|
|
|
|=([=ship =path] path)
|
2020-07-22 15:54:34 +03:00
|
|
|
?~ paths ~
|
|
|
|
[%give %kick paths ~]~
|
2020-07-23 10:42:41 +03:00
|
|
|
::
|
|
|
|
++ pass-store
|
|
|
|
|= [=wire =task:agent:gall]
|
|
|
|
^- card
|
|
|
|
[%pass wire %agent [our.bol %contact-store] task]
|
2020-07-17 04:21:30 +03:00
|
|
|
--
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
=^ cards state
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%json
|
|
|
|
(poke-json:cc !<(json vase))
|
|
|
|
::
|
2020-09-01 04:54:39 +03:00
|
|
|
%contact-action
|
2019-12-14 02:22:36 +03:00
|
|
|
(poke-contact-action:cc !<(contact-action vase))
|
|
|
|
::
|
|
|
|
%contact-hook-action
|
|
|
|
(poke-hook-action:cc !<(contact-hook-action vase))
|
2020-12-01 00:07:04 +03:00
|
|
|
::
|
|
|
|
%import
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
(poke-import:cc q.vase)
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ path (on-watch:def path)
|
|
|
|
[%contacts *] [(watch-contacts:cc t.path) this]
|
2020-04-14 00:37:51 +03:00
|
|
|
[%synced *] [(watch-synced:cc t.path) this]
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-agent
|
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ -.sign (on-agent:def wire sign)
|
|
|
|
%kick [(kick:cc wire) this]
|
|
|
|
%watch-ack
|
|
|
|
=^ cards state
|
2020-09-01 04:54:39 +03:00
|
|
|
(watch-ack:cc wire p.sign)
|
2019-12-14 02:22:36 +03:00
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
%fact
|
|
|
|
?+ p.cage.sign (on-agent:def wire sign)
|
|
|
|
%contact-update
|
|
|
|
=^ cards state
|
|
|
|
(fact-contact-update:cc wire !<(contact-update q.cage.sign))
|
|
|
|
[cards this]
|
|
|
|
::
|
|
|
|
%group-update
|
|
|
|
=^ cards state
|
2020-05-25 08:52:54 +03:00
|
|
|
(fact-group-update:cc wire !<(update:group-store q.cage.sign))
|
2019-12-14 02:22:36 +03:00
|
|
|
[cards this]
|
|
|
|
::
|
2020-08-17 05:41:24 +03:00
|
|
|
%invite-update [~ this]
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
2020-12-01 00:07:04 +03:00
|
|
|
++ on-peek
|
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
|
|
|
?+ path (on-peek:def path)
|
|
|
|
[%x %export ~]
|
|
|
|
``noun+!>(state)
|
|
|
|
==
|
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?. ?=([%try-rejoin @ @ *] wire)
|
|
|
|
(on-arvo:def wire sign-arvo)
|
|
|
|
=/ nack-count=@ud (slav %ud i.t.wire)
|
|
|
|
=/ who=@p (slav %p i.t.t.wire)
|
|
|
|
=/ pax t.t.t.wire
|
|
|
|
?> ?=([%b %wake *] sign-arvo)
|
|
|
|
~? ?=(^ error.sign-arvo)
|
|
|
|
"behn errored in backoff timers, continuing anyway"
|
|
|
|
:_ this
|
|
|
|
[(try-rejoin:cc who pax +(nack-count))]~
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|_ bol=bowl:gall
|
2020-06-15 11:09:03 +03:00
|
|
|
++ grp ~(. grpl bol)
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
++ poke-json
|
|
|
|
|= jon=json
|
|
|
|
^- (quip card _state)
|
|
|
|
(poke-contact-action (json-to-action jon))
|
|
|
|
::
|
|
|
|
++ poke-contact-action
|
|
|
|
|= act=contact-action
|
|
|
|
^- (quip card _state)
|
2020-01-29 21:42:33 +03:00
|
|
|
:_ state
|
2020-01-23 01:44:21 +03:00
|
|
|
?+ -.act !!
|
2020-01-29 21:42:33 +03:00
|
|
|
%edit (handle-contact-action path.act ship.act act)
|
|
|
|
%add (handle-contact-action path.act ship.act act)
|
|
|
|
%remove (handle-contact-action path.act ship.act act)
|
2020-01-23 01:44:21 +03:00
|
|
|
==
|
2020-04-21 21:58:37 +03:00
|
|
|
::
|
|
|
|
++ handle-contact-action
|
|
|
|
|= [=path =ship act=contact-action]
|
|
|
|
^- (list card)
|
|
|
|
:: local
|
|
|
|
?: (team:title our.bol src.bol)
|
2020-06-10 06:14:25 +03:00
|
|
|
?. |(=(path /~/default) (~(has by synced) path)) ~
|
2020-04-21 21:58:37 +03:00
|
|
|
=/ shp ?:(=(path /~/default) our.bol (~(got by synced) path))
|
|
|
|
=/ appl ?:(=(shp our.bol) %contact-store %contact-hook)
|
|
|
|
[%pass / %agent [shp appl] %poke %contact-action !>(act)]~
|
|
|
|
:: foreign
|
|
|
|
=/ shp (~(got by synced) path)
|
|
|
|
?. |(=(shp our.bol) =(src.bol ship)) ~
|
|
|
|
:: scry group to check if ship is a member
|
|
|
|
=/ =group (need (group-scry path))
|
2020-05-25 08:52:54 +03:00
|
|
|
?. (~(has in members.group) shp) ~
|
2020-04-21 21:58:37 +03:00
|
|
|
[%pass / %agent [our.bol %contact-store] %poke %contact-action !>(act)]~
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
++ poke-hook-action
|
|
|
|
|= act=contact-hook-action
|
|
|
|
^- (quip card _state)
|
|
|
|
?- -.act
|
|
|
|
%add-owned
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
=/ contact-path [%contacts path.act]
|
|
|
|
?: (~(has by synced) path.act)
|
|
|
|
[~ state]
|
|
|
|
=. synced (~(put by synced) path.act our.bol)
|
|
|
|
:_ state
|
2020-04-15 00:57:21 +03:00
|
|
|
:~ [%pass contact-path %agent [our.bol %contact-store] %watch contact-path]
|
2020-04-21 21:58:37 +03:00
|
|
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]
|
2020-04-15 00:57:21 +03:00
|
|
|
==
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
%add-synced
|
|
|
|
?> (team:title our.bol src.bol)
|
2020-01-30 02:02:03 +03:00
|
|
|
?: (~(has by synced) path.act) [~ state]
|
2020-01-15 03:06:38 +03:00
|
|
|
=. synced (~(put by synced) path.act ship.act)
|
|
|
|
=/ contact-path [%contacts path.act]
|
2019-12-14 02:22:36 +03:00
|
|
|
:_ state
|
2020-04-15 00:57:21 +03:00
|
|
|
:~ [%pass contact-path %agent [ship.act %contact-hook] %watch contact-path]
|
2020-04-21 21:58:37 +03:00
|
|
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]
|
2020-04-15 00:57:21 +03:00
|
|
|
==
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
%remove
|
|
|
|
=/ ship (~(get by synced) path.act)
|
2020-01-30 02:02:03 +03:00
|
|
|
?~ ship [~ state]
|
2019-12-14 02:22:36 +03:00
|
|
|
?: &(=(u.ship our.bol) (team:title our.bol src.bol))
|
|
|
|
:: delete one of our.bol own paths
|
|
|
|
:_ state(synced (~(del by synced) path.act))
|
|
|
|
%- zing
|
|
|
|
:~ (pull-wire [%contacts path.act])
|
2020-01-25 02:57:29 +03:00
|
|
|
[%give %kick ~[[%contacts path.act]] ~]~
|
2020-04-21 21:58:37 +03:00
|
|
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]~
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
?. |(=(u.ship src.bol) (team:title our.bol src.bol))
|
|
|
|
:: if neither ship = source or source = us, do nothing
|
|
|
|
[~ state]
|
|
|
|
:: delete a foreign ship's path
|
2020-04-21 21:58:37 +03:00
|
|
|
=/ cards
|
|
|
|
(handle-contact-action path.act our.bol [%remove path.act our.bol])
|
2020-04-15 00:57:21 +03:00
|
|
|
:_ state(synced (~(del by synced) path.act))
|
|
|
|
%- zing
|
|
|
|
:~ (pull-wire [%contacts path.act])
|
2020-04-21 21:58:37 +03:00
|
|
|
[%give %fact [/synced]~ %contact-hook-update !>([%initial synced])]~
|
|
|
|
cards
|
2020-04-15 00:57:21 +03:00
|
|
|
==
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
2020-12-01 00:07:04 +03:00
|
|
|
++ poke-import
|
|
|
|
|= arc=*
|
|
|
|
^- (quip card _state)
|
2020-12-02 10:03:05 +03:00
|
|
|
=/ sty=state-three
|
|
|
|
[%3 (remake-map ;;((tree [path ship]) +<.arc)) ;;(? +>.arc)]
|
2020-12-01 00:07:04 +03:00
|
|
|
:_ sty
|
|
|
|
%+ turn ~(tap by synced.sty)
|
|
|
|
|= [=path =ship]
|
|
|
|
^- card
|
|
|
|
=/ contact-path [%contacts path]
|
|
|
|
?: =(our.bol ship)
|
|
|
|
[%pass contact-path %agent [our.bol %contact-store] %watch contact-path]
|
|
|
|
(try-rejoin ship contact-path 0)
|
|
|
|
::
|
|
|
|
++ try-rejoin
|
|
|
|
|= [who=@p pax=path nack-count=@ud]
|
|
|
|
^- card
|
|
|
|
=/ =wire
|
|
|
|
[%try-rejoin (scot %ud nack-count) (scot %p who) pax]
|
|
|
|
[%pass wire %agent [who %contact-hook] %watch pax]
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
++ watch-contacts
|
|
|
|
|= pax=path
|
|
|
|
^- (list card)
|
|
|
|
?> ?=(^ pax)
|
|
|
|
?> (~(has by synced) pax)
|
|
|
|
:: scry groups to check if ship is a member
|
|
|
|
=/ =group (need (group-scry pax))
|
2020-05-25 08:52:54 +03:00
|
|
|
?> (~(has in members.group) src.bol)
|
2019-12-14 02:22:36 +03:00
|
|
|
=/ contacts (need (contacts-scry pax))
|
2020-04-21 21:58:37 +03:00
|
|
|
[%give %fact ~ %contact-update !>([%contacts pax contacts])]~
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
2020-04-14 00:37:51 +03:00
|
|
|
++ watch-synced
|
|
|
|
|= pax=path
|
|
|
|
^- (list card)
|
|
|
|
?> (team:title our.bol src.bol)
|
|
|
|
[%give %fact ~ %contact-hook-update !>([%initial synced])]~
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
++ watch-ack
|
|
|
|
|= [wir=wire saw=(unit tang)]
|
|
|
|
^- (quip card _state)
|
|
|
|
?~ saw
|
|
|
|
[~ state]
|
2020-12-01 00:07:04 +03:00
|
|
|
?: ?=([%try-rejoin @ *] wir)
|
|
|
|
=/ nack-count=@ud (slav %ud i.t.wir)
|
|
|
|
=/ wakeup=@da
|
|
|
|
(add now.bol (mul ~s1 (bex (min 19 nack-count))))
|
|
|
|
:_ state
|
|
|
|
[%pass wir %arvo %b %wait wakeup]~
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
?> ?=(^ wir)
|
2020-02-13 01:29:29 +03:00
|
|
|
[~ state(synced (~(del by synced) t.wir))]
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
2020-07-17 04:21:30 +03:00
|
|
|
++ migrate
|
|
|
|
|= wir=wire
|
|
|
|
^- wire
|
|
|
|
?> ?=([%contacts @ @ *] wir)
|
|
|
|
[%contacts %ship t.wir]
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
++ kick
|
|
|
|
|= wir=wire
|
|
|
|
^- (list card)
|
|
|
|
?+ wir !!
|
2020-12-01 00:07:04 +03:00
|
|
|
[%try-rejoin @ @ *]
|
|
|
|
$(wir t.t.t.wir)
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
[%inv ~]
|
|
|
|
[%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]~
|
|
|
|
::
|
2020-06-24 03:28:57 +03:00
|
|
|
[%group ~]
|
|
|
|
[%pass /group %agent [our.bol %group-store] %watch /groups]~
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
[%contacts @ *]
|
2020-09-01 04:54:39 +03:00
|
|
|
=/ wir
|
|
|
|
?: =(%ship i.t.wir)
|
2020-07-17 04:21:30 +03:00
|
|
|
wir
|
|
|
|
(migrate wir)
|
|
|
|
?> ?=([%contacts @ @ *] wir)
|
2019-12-14 02:22:36 +03:00
|
|
|
?. (~(has by synced) t.wir) ~
|
|
|
|
=/ =ship (~(got by synced) t.wir)
|
|
|
|
?: =(ship our.bol)
|
|
|
|
[%pass wir %agent [our.bol %contact-store] %watch wir]~
|
|
|
|
[%pass wir %agent [ship %contact-hook] %watch wir]~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ fact-contact-update
|
|
|
|
|= [wir=wire fact=contact-update]
|
|
|
|
^- (quip card _state)
|
|
|
|
|^
|
|
|
|
?: (team:title our.bol src.bol)
|
|
|
|
(local fact)
|
2020-01-30 02:02:03 +03:00
|
|
|
:_ state
|
2019-12-14 02:22:36 +03:00
|
|
|
(foreign fact)
|
|
|
|
::
|
2020-01-29 21:42:33 +03:00
|
|
|
++ give-fact
|
|
|
|
|= [=path update=contact-update]
|
|
|
|
^- (list card)
|
|
|
|
[%give %fact ~[[%contacts path]] %contact-update !>(update)]~
|
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
++ local
|
|
|
|
|= fact=contact-update
|
2020-01-30 02:02:03 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
?+ -.fact [~ state]
|
2019-12-14 02:22:36 +03:00
|
|
|
%add
|
2020-01-30 02:02:03 +03:00
|
|
|
:_ state
|
2020-01-29 21:42:33 +03:00
|
|
|
(give-fact path.fact [%add path.fact ship.fact contact.fact])
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
%edit
|
2020-01-30 02:02:03 +03:00
|
|
|
:_ state
|
2020-01-29 21:42:33 +03:00
|
|
|
(give-fact path.fact [%edit path.fact ship.fact edit-field.fact])
|
2020-01-30 02:02:03 +03:00
|
|
|
::
|
|
|
|
%delete
|
|
|
|
=. synced (~(del by synced) path.fact)
|
2020-05-25 08:52:54 +03:00
|
|
|
`state
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ foreign
|
|
|
|
|= fact=contact-update
|
2020-01-29 21:42:33 +03:00
|
|
|
^- (list card)
|
|
|
|
?+ -.fact ~
|
2019-12-14 02:22:36 +03:00
|
|
|
%contacts
|
|
|
|
=/ owner (~(got by synced) path.fact)
|
|
|
|
?> =(owner src.bol)
|
contact-hook: less destructive catch-up on-sub
(Re)subscribing gets us a %contacts update, containing the full set of
contacts as it currently exists.
Previously, we would fully delete our local state, only to recreate it
using the data from the update.
Now, we never delete existing data, instead only creating if we don't
have it yet, and adding, removing or recreating contacts if they
changed.
In the future, we'll want an easy way to turn two contacts into an %edit
diff, to let us apply correct semantics to individual contacts, too.
2020-03-27 16:21:03 +03:00
|
|
|
=/ have-contacts=(unit contacts)
|
|
|
|
(contacts-scry path.fact)
|
|
|
|
?~ have-contacts
|
|
|
|
:: if we don't have any contacts yet,
|
|
|
|
:: create the entry, and %add every contact
|
|
|
|
::
|
|
|
|
:- (contact-poke [%create path.fact])
|
|
|
|
%+ turn ~(tap by contacts.fact)
|
|
|
|
|= [=ship =contact]
|
|
|
|
(contact-poke [%add path.fact ship contact])
|
|
|
|
:: if we already have some, decide between %add, %remove and recreate
|
|
|
|
:: on a per-contact basis
|
|
|
|
::
|
|
|
|
%- zing
|
|
|
|
%+ turn
|
|
|
|
%~ tap in
|
|
|
|
%- ~(uni in ~(key by contacts.fact))
|
|
|
|
~(key by u.have-contacts)
|
|
|
|
|= =ship
|
|
|
|
^- (list card)
|
|
|
|
=/ have=(unit contact) (~(get by u.have-contacts) ship)
|
|
|
|
=/ want=(unit contact) (~(get by contacts.fact) ship)
|
|
|
|
?~ have
|
|
|
|
[(contact-poke %add path.fact ship (need want))]~
|
|
|
|
?~ want
|
|
|
|
[(contact-poke %remove path.fact ship)]~
|
|
|
|
?: =(u.want u.have) ~
|
|
|
|
::TODO probably want an %all edit-field that resolves to more granular
|
|
|
|
:: updates within the contact-store?
|
|
|
|
:~ (contact-poke %remove path.fact ship)
|
|
|
|
(contact-poke %add path.fact ship u.want)
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
%add
|
2020-04-21 21:58:37 +03:00
|
|
|
=/ owner (~(get by synced) path.fact)
|
|
|
|
?~ owner ~
|
|
|
|
?> |(=(u.owner src.bol) =(src.bol ship.fact))
|
2020-01-29 21:42:33 +03:00
|
|
|
~[(contact-poke [%add path.fact ship.fact contact.fact])]
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
%remove
|
2020-04-21 21:58:37 +03:00
|
|
|
=/ owner (~(get by synced) path.fact)
|
|
|
|
?~ owner ~
|
|
|
|
?> |(=(u.owner src.bol) =(src.bol ship.fact))
|
2020-05-25 08:52:54 +03:00
|
|
|
~[(contact-poke [%remove path.fact ship.fact])]
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
%edit
|
|
|
|
=/ owner (~(got by synced) path.fact)
|
2020-01-23 01:44:21 +03:00
|
|
|
?> |(=(owner src.bol) =(src.bol ship.fact))
|
2020-01-29 21:42:33 +03:00
|
|
|
~[(contact-poke [%edit path.fact ship.fact edit-field.fact])]
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ fact-group-update
|
2020-05-25 08:52:54 +03:00
|
|
|
|= [wir=wire fact=update:group-store]
|
2019-12-14 02:22:36 +03:00
|
|
|
^- (quip card _state)
|
2020-06-29 09:20:14 +03:00
|
|
|
?: ?=(%initial -.fact)
|
|
|
|
[~ state]
|
|
|
|
=/ group=(unit group)
|
|
|
|
(scry-group:grp resource.fact)
|
2019-12-14 02:22:36 +03:00
|
|
|
|^
|
|
|
|
?+ -.fact [~ state]
|
2020-05-25 08:52:54 +03:00
|
|
|
%initial-group (initial-group +.fact)
|
|
|
|
%remove-members (remove +.fact)
|
|
|
|
%remove-group (unbundle +.fact)
|
2019-12-14 02:22:36 +03:00
|
|
|
==
|
|
|
|
::
|
2020-05-25 08:52:54 +03:00
|
|
|
++ initial-group
|
2020-06-15 11:09:03 +03:00
|
|
|
|= [rid=resource =^group]
|
2020-05-25 08:52:54 +03:00
|
|
|
^- (quip card _state)
|
2020-06-15 11:09:03 +03:00
|
|
|
?: hidden.group [~ state]
|
2020-05-25 08:52:54 +03:00
|
|
|
=/ =path
|
2020-06-08 10:53:16 +03:00
|
|
|
(en-path:resource rid)
|
2020-05-25 08:52:54 +03:00
|
|
|
?: (~(has by synced) path)
|
|
|
|
[~ state]
|
2020-06-08 10:53:16 +03:00
|
|
|
(poke-hook-action %add-synced entity.rid path)
|
2020-05-25 08:52:54 +03:00
|
|
|
::
|
2019-12-14 02:22:36 +03:00
|
|
|
++ unbundle
|
2020-06-08 10:53:16 +03:00
|
|
|
|= [rid=resource ~]
|
2019-12-14 02:22:36 +03:00
|
|
|
^- (quip card _state)
|
2020-05-25 08:52:54 +03:00
|
|
|
=/ =path
|
2020-06-08 10:53:16 +03:00
|
|
|
(en-path:resource rid)
|
2019-12-14 02:22:36 +03:00
|
|
|
?. (~(has by synced) path)
|
2020-06-29 09:20:14 +03:00
|
|
|
?~ (contacts-scry path)
|
|
|
|
[~ state]
|
2020-04-14 00:37:51 +03:00
|
|
|
:_ state
|
|
|
|
[(contact-poke [%delete path])]~
|
2019-12-14 02:22:36 +03:00
|
|
|
:_ state(synced (~(del by synced) path))
|
2020-01-30 02:02:03 +03:00
|
|
|
:~ [%pass [%contacts path] %agent [our.bol %contact-store] %leave ~]
|
|
|
|
[(contact-poke [%delete path])]
|
|
|
|
==
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
++ remove
|
2020-06-08 10:53:16 +03:00
|
|
|
|= [rid=resource ships=(set ship)]
|
2019-12-14 02:22:36 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
:: if pax is synced, remove member from contacts and kick their sub
|
2020-06-29 09:20:14 +03:00
|
|
|
?~ group
|
|
|
|
[~ state]
|
|
|
|
?: hidden.u.group [~ state]
|
2020-05-25 08:52:54 +03:00
|
|
|
=/ =path
|
2020-06-08 10:53:16 +03:00
|
|
|
(en-path:resource rid)
|
2020-01-30 02:02:03 +03:00
|
|
|
=/ owner=(unit ship) (~(get by synced) path)
|
|
|
|
?~ owner
|
|
|
|
:_ state
|
2020-05-25 08:52:54 +03:00
|
|
|
%+ turn ~(tap in ships)
|
2020-01-30 02:02:03 +03:00
|
|
|
|= =ship
|
|
|
|
(contact-poke [%remove path ship])
|
2019-12-14 02:22:36 +03:00
|
|
|
:_ state
|
|
|
|
%- zing
|
2020-05-25 08:52:54 +03:00
|
|
|
%+ turn ~(tap in ships)
|
2019-12-14 02:22:36 +03:00
|
|
|
|= =ship
|
2020-01-25 02:57:29 +03:00
|
|
|
:~ [%give %kick ~[[%contacts path]] `ship]
|
2020-01-30 02:02:03 +03:00
|
|
|
?: =(ship our.bol)
|
|
|
|
(contact-poke [%delete path])
|
2019-12-14 02:22:36 +03:00
|
|
|
(contact-poke [%remove path ship])
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ invite-poke
|
2020-10-22 20:17:15 +03:00
|
|
|
|= act=action:inv
|
2019-12-14 02:22:36 +03:00
|
|
|
^- card
|
|
|
|
[%pass / %agent [our.bol %invite-store] %poke %invite-action !>(act)]
|
|
|
|
::
|
|
|
|
++ contact-poke
|
|
|
|
|= act=contact-action
|
|
|
|
^- card
|
|
|
|
[%pass / %agent [our.bol %contact-store] %poke %contact-action !>(act)]
|
|
|
|
::
|
|
|
|
++ contacts-scry
|
|
|
|
|= pax=path
|
|
|
|
^- (unit contacts)
|
2020-05-19 23:53:55 +03:00
|
|
|
=. pax
|
|
|
|
;: weld
|
|
|
|
/(scot %p our.bol)/contact-store/(scot %da now.bol)/contacts
|
|
|
|
pax
|
|
|
|
/noun
|
|
|
|
==
|
2019-12-14 02:22:36 +03:00
|
|
|
.^((unit contacts) %gx pax)
|
|
|
|
::
|
|
|
|
++ group-scry
|
|
|
|
|= pax=path
|
2020-05-19 23:53:55 +03:00
|
|
|
.^ (unit group)
|
|
|
|
%gx
|
2020-06-23 05:13:03 +03:00
|
|
|
;:(weld /(scot %p our.bol)/group-store/(scot %da now.bol) /groups pax /noun)
|
2020-05-19 23:53:55 +03:00
|
|
|
==
|
2019-12-14 02:22:36 +03:00
|
|
|
::
|
|
|
|
++ pull-wire
|
|
|
|
|= pax=path
|
|
|
|
^- (list card)
|
|
|
|
?> ?=(^ pax)
|
|
|
|
=/ shp (~(get by synced) t.pax)
|
|
|
|
?~ shp ~
|
|
|
|
?: =(u.shp our.bol)
|
2020-03-07 02:15:03 +03:00
|
|
|
[%pass pax %agent [our.bol %contact-store] %leave ~]~
|
2020-03-09 22:29:49 +03:00
|
|
|
[%pass pax %agent [u.shp %contact-hook] %leave ~]~
|
2019-12-14 02:22:36 +03:00
|
|
|
--
|