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