chat-hook: fix synced map getting out of sync with outgoing subscriptions
state-4
state-5
state-6
+ state-7
==
::
++$ state-7 [%7 state-base]
+$ state-6 [%6 state-base]
+$ state-5 [%5 state-base]
+$ state-4 [%4 state-base]
$% [%chat-update update:store]
==
--
-=| state-6
+=| state-7
=* state -
::
%- agent:dbug
=/ old !<(versioned-state old-vase)
=| cards=(list card)
|-
- ?: ?=(%6 -.old)
+ ?: ?=(%7 -.old)
[cards this(state old)]
+ ?: ?=(%6 -.old)
+ =. cards
+ %+ weld cards
+ ^- (list card)
+ [%pass /s %agent [our.bol %chat-hook] %poke %noun !>(%fix-out-of-sync)]~
+ $(-.old %7)
?: ?=(?(%3 %4 %5) -.old)
=. cards
%+ weld cards
?+ mark (on-poke:def mark vase)
%json (poke-json:cc !<(json vase))
%chat-action (poke-chat-action:cc !<(action:store vase))
- %noun (poke-fix-dms:cc %fix-dms)
+ %noun (poke-noun:cc !<(?(%fix-dm %fix-out-of-sync) vase))
::
%chat-hook-action
(poke-chat-hook-action:cc !<(action:hook vase))
|_ bol=bowl:gall
++ grp ~(. grpl bol)
::
-++ poke-fix-dms
- |= a=%fix-dms
+++ poke-noun
+ |= a=?(%fix-dm %fix-out-of-sync)
^- (quip card _state)
+ |^
:_ state
+ ?- a
+ %fix-dm (fix-dm %fix-dm)
+ %fix-out-of-sync (fix-out-of-sync %fix-out-of-sync)
+ ==
+ ::
+ ++ fix-out-of-sync
+ |= b=%fix-out-of-sync
+ ^- (list card)
+ %- zing
+ %+ turn ~(tap by synced)
+ |= [=path host=ship]
+ ^- (list card)
+ ?: =(host our.bol) ~
+ ?> ?=([@ @ ~] path)
+ =/ =ship (slav %p i.path)
+ :~ =- [%pass / %agent [our.bol %chat-hook] %poke %chat-hook-action -]
+ !> ^- action:hook
+ [%remove path]
+ ::
+ =- [%pass / %agent [our.bol %chat-hook] %poke %chat-hook-action -]
+ !> ^- action:hook
+ [%add-synced ship path %.y]
+ ==
+ ::
+ ++ fix-dm
+ |= b=%fix-dm
+ ^- (list card)
%- zing
%+ turn
~(tap by synced)
!> ^- action:store
[%messages new-dm envelopes.u.mailbox]
==
+ --
::
++ poke-json
|= jon=json
