chat-store: responded to comments, cleaned up
|%
+$ card card:agent:gall
+$ versioned-state
- $% state-zero
- state-one
- state-two
- state-three
+ $% state-0
+ state-1
+ state-2
==
::
-+$ state-zero [%0 =inbox:store]
-+$ state-one [%1 =inbox:store]
-+$ state-two [%2 =inbox:store]
-+$ state-three [%3 =inbox:store]
++$ state-0 [%0 =inbox:store]
++$ state-1 [%1 =inbox:store]
++$ state-2 [%2 =inbox:store]
+$ admin-action
$% [%trim ~]
==
--
::
-=| state-three
+=| state-2
=* state -
::
%- agent:dbug
++ on-save !>(state)
++ on-load
|= old-vase=vase
+ ^- (quip card _this)
+ |^
=/ old !<(versioned-state old-vase)
- ?: ?=(%3 -.old)
- [~ this(state old)]
- ?: ?=(%2 -.old)
- :_ this(state [%3 inbox.old])
+ =? old ?=(%0 -.old)
+ (old-to-2 inbox.old)
+ =? old ?=(%1 -.old)
+ (old-to-2 inbox.old)
+ :_ this(state [%2 inbox.old])
[%pass /trim %agent [our.bowl %chat-store] %poke %noun !>([%trim ~])]~
- =/ reversed-inbox=inbox:store
- %- ~(run by inbox.old)
+ ::
+ ++ old-to-2
+ |= =inbox:store
+ ^- state-2
+ :- %2
+ %- ~(run by inbox)
|= =mailbox:store
^- mailbox:store
[config.mailbox (flop envelopes.mailbox)]
- :_ this(state [%3 reversed-inbox])
- [%pass /trim %agent [our.bowl %chat-store] %poke %noun !>([%trim ~])]~
+ --
::
++ on-poke
~/ %chat-store-poke
?+ mark (on-poke:def mark vase)
%json (poke-json:cc !<(json vase))
%chat-action (poke-chat-action:cc !<(action:store vase))
- %noun (poke-noun:cc !<(admin-action vase))
+ %noun [~ (poke-noun:cc !<(admin-action vase))]
==
[cards this]
::
::
++ poke-noun
|= nou=admin-action
- ^- (quip card _state)
+ ^- _state
~& %trimming-chat-store
- :- ~
- :- %3
+ %_ state
+ inbox
%- ~(urn by inbox)
|= [=path mailbox:store]
^- mailbox:store
=/ len (lent out)
~& [path [%old (lent envelopes)] [%new len]]
[[len len] (flop out)]
+ ==
::
++ poke-json
|= jon=json
