chat-hook: upgrade state to stop storing cards

The card type has changed, so we need a state upgrade.  As I understand
it, these existed for a particular upgrade to get around the fact that
Ford Turbo updates apps in random order.  In Ford Fusion, all apps are
started in parallel before any of their moves are emitted, so this is
no longer a problem.

Since these will no longer be needed and they don't load properly when
+card changes, we deleted them.  While trying to find a bug that I
introduced, I refactored +on-load a little bit -- I can revert this if
it's confusing.
This commit is contained in:
Philip Monk 2020-06-12 21:12:36 -07:00
parent 8cf4e4bb38
commit 3c5541432a
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC

View File

@ -14,11 +14,17 @@
+$ versioned-state +$ versioned-state
$% state-0 $% state-0
state-1 state-1
state-2
==
::
+$ state-2
$: %2
state-base
== ==
:: ::
+$ state-1 +$ state-1
$: %1 $: %1
loaded-cards=(list card) loaded-cards=*
state-base state-base
== ==
+$ state-0 [%0 state-base] +$ state-0 [%0 state-base]
@ -39,7 +45,7 @@
$% [%chat-update update:store] $% [%chat-update update:store]
== ==
-- --
=| state-1 =| state-2
=* state - =* state -
:: ::
%- agent:dbug %- agent:dbug
@ -66,28 +72,30 @@
^- (quip card _this) ^- (quip card _this)
|^ |^
=/ old !<(versioned-state old-vase) =/ old !<(versioned-state old-vase)
?: ?=(%1 -.old) =^ moves state
:_ this(state old) ^- (quip card state-2)
%+ murn ~(tap by wex.bol) ?: ?=(%2 -.old)
|= [[=wire =ship =term] *] ^- (quip card state-2)
^- (unit card) `old
?. &(?=([%mailbox *] wire) =(our.bol ship) =(%chat-store term)) ::
~ ?: ?=(%1 -.old)
`[%pass wire %agent [our.bol %chat-store] %leave ~] ^- (quip card state-2)
:: path structure ugprade logic :_ [%2 +>.old]
:: %+ murn ~(tap by wex.bol)
=/ keys=(set path) (scry:cc (set path) %chat-store /keys) |= [[=wire =ship =term] *]
=/ upgraded-state ^- (unit card)
%* . *state-1 ?. &(?=([%mailbox *] wire) =(our.bol ship) =(%chat-store term))
synced synced ~
invite-created invite-created `[%pass wire %agent [our.bol %chat-store] %leave ~]
allow-history allow-history ^- (quip card state-2)
loaded-cards :: path structure ugprade logic
%- zing ::
^- (list (list card)) =/ keys=(set path) (scry:cc (set path) %chat-store /keys)
%+ turn ~(tap in keys) generate-cards :_ [%2 +.old]
== %- zing
[loaded-cards.upgraded-state this(state upgraded-state)] ^- (list (list card))
(turn ~(tap in keys) generate-cards)
[moves this]
:: ::
++ generate-cards ++ generate-cards
|= old-chat=path |= old-chat=path
@ -233,10 +241,7 @@
?+ mark (on-poke:def mark vase) ?+ mark (on-poke:def mark vase)
%json (poke-json:cc !<(json vase)) %json (poke-json:cc !<(json vase))
%chat-action (poke-chat-action:cc !<(action:store vase)) %chat-action (poke-chat-action:cc !<(action:store vase))
%noun %noun [~ state]
?: =(%store-load q.vase)
[loaded-cards.state state(loaded-cards ~)]
[~ state]
:: ::
%chat-hook-action %chat-hook-action
(poke-chat-hook-action:cc !<(action:hook vase)) (poke-chat-hook-action:cc !<(action:hook vase))
@ -457,7 +462,7 @@
(chats-of-group pax) (chats-of-group pax)
|= chat=path |= chat=path
^- (list card) ^- (list card)
=/ owner (~(get by synced) chat) =/ owner (~(get by synced.state) chat)
?~ owner ~ ?~ owner ~
?. =(u.owner our.bol) ~ ?. =(u.owner our.bol) ~
%- zing %- zing