contact-hook: upgrade paths on OTA

This commit is contained in:
Liam Fitzgerald 2020-07-17 11:21:30 +10:00
parent 2c550bfcaf
commit 2509642042
2 changed files with 54 additions and 10 deletions

View File

@ -15,16 +15,18 @@
+$ versioned-state
$% state-zero
state-one
state-two
==
::
+$ state-zero [%0 state-base]
+$ state-one [%1 state-base]
+$ state-two [%2 state-base]
+$ state-base
$: =synced
invite-created=_|
==
--
=| state-one
=| state-two
=* state -
%- agent:dbug
%+ verb |
@ -48,15 +50,45 @@
|= old-vase=vase
^- (quip card _this)
=/ old !<(versioned-state old-vase)
=| cards=(list card)
|^
|- ^- (quip card _this)
?: ?=(%2 -.old)
[cards this(state old)]
?: ?=(%1 -.old)
[~ this(state old)]
=/ upgraded-state
%* . *state-one
synced synced
invite-created invite-created
%_ $
-.old %2
::
synced.old
%- malt
%+ turn
~(tap by synced.old)
|= [=path =ship]
[ship+path ship]
::
cards
^- (list card)
%+ welp
:~ [%pass /group %agent [our.bol %group-store] %leave ~]
[%pass /group %agent [our.bol %group-store] %watch /groups]
kick-old-subs
==
cards
==
:_ this(state upgraded-state)
[%pass /group %agent [our.bol %group-store] %watch /updates]~
%_ $
-.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)
[%give %kick paths ~]
--
::
++ on-poke
|= [=mark =vase]
@ -227,6 +259,12 @@
?> ?=(^ wir)
[~ state(synced (~(del by synced) t.wir))]
::
++ migrate
|= wir=wire
^- wire
?> ?=([%contacts @ @ *] wir)
[%contacts %ship t.wir]
::
++ kick
|= wir=wire
^- (list card)
@ -238,6 +276,11 @@
[%pass /group %agent [our.bol %group-store] %watch /groups]~
::
[%contacts @ *]
=/ wir
?: =(%ship i.t.wir)
wir
(migrate wir)
?> ?=([%contacts @ @ *] wir)
?. (~(has by synced) t.wir) ~
=/ =ship (~(got by synced) t.wir)
?: =(ship our.bol)

View File

@ -6,6 +6,7 @@
+$ versioned-state
$% state-zero
state-one
state-two
==
::
+$ rolodex-0 (map path contacts-0)
@ -35,7 +36,7 @@
==
--
::
=| state-one
=| state-two
=* state -
%- agent:dbug
^- agent:gall
@ -89,7 +90,7 @@
color.con
~
==
$(old [%1 new-rolodex])]
$(old [%1 new-rolodex])
::
++ on-poke
|= [=mark =vase]