contacts: import/export

This commit is contained in:
Isaac Visintainer 2020-11-30 13:07:04 -08:00
parent 9ea14aa558
commit 4f0e599cb1
2 changed files with 70 additions and 4 deletions

View File

@ -132,6 +132,10 @@
:: ::
%contact-hook-action %contact-hook-action
(poke-hook-action:cc !<(contact-hook-action vase)) (poke-hook-action:cc !<(contact-hook-action vase))
::
%import
?> (team:title our.bol src.bol)
(poke-import:cc q.vase)
== ==
[cards this] [cards this]
:: ::
@ -170,8 +174,27 @@
== ==
:: ::
++ on-leave on-leave:def ++ on-leave on-leave:def
++ on-peek on-peek:def ++ on-peek
++ on-arvo on-arvo:def |= =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))]~
::
++ on-fail on-fail:def ++ on-fail on-fail:def
-- --
:: ::
@ -260,6 +283,26 @@
== ==
== ==
:: ::
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-three ;;(state-three arc)
:_ 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]
::
++ watch-contacts ++ watch-contacts
|= pax=path |= pax=path
^- (list card) ^- (list card)
@ -282,6 +325,13 @@
^- (quip card _state) ^- (quip card _state)
?~ saw ?~ saw
[~ state] [~ state]
?: ?=([%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]~
::
?> ?=(^ wir) ?> ?=(^ wir)
[~ state(synced (~(del by synced) t.wir))] [~ state(synced (~(del by synced) t.wir))]
:: ::
@ -295,6 +345,9 @@
|= wir=wire |= wir=wire
^- (list card) ^- (list card)
?+ wir !! ?+ wir !!
[%try-rejoin @ @ *]
$(wir t.t.t.wir)
::
[%inv ~] [%inv ~]
[%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]~ [%pass /inv %agent [our.bol %invite-store] %watch /invitatory/contacts]~
:: ::

View File

@ -122,7 +122,11 @@
=^ cards state =^ cards state
?+ mark (on-poke:def mark vase) ?+ mark (on-poke:def mark vase)
::%json (poke-json:cc !<(json vase)) ::%json (poke-json:cc !<(json vase))
%contact-action (poke-contact-action:cc !<(contact-action vase)) %contact-action
(poke-contact-action:cc !<(contact-action vase))
::
%import
(poke-import:cc q.vase)
== ==
[cards this] [cards this]
:: ::
@ -169,6 +173,9 @@
?~ contacts ?~ contacts
~ ~
``noun+!>((~(get by u.contacts) ship)) ``noun+!>((~(get by u.contacts) ship))
::
[%x %export ~]
``noun+!>(state)
== ==
:: ::
++ on-agent on-agent:def ++ on-agent on-agent:def
@ -197,6 +204,12 @@
%edit (handle-edit +.action) %edit (handle-edit +.action)
== ==
:: ::
++ poke-import
|= arc=*
^- (quip card _state)
=/ sty=state-three ;;(state-three arc)
[~ sty]
::
++ handle-create ++ handle-create
|= =path |= =path
^- (quip card _state) ^- (quip card _state)