chat-store: responded to comments, cleaned up

This commit is contained in:
Logan Allen 2020-06-26 15:51:55 -04:00 committed by Ted Blackman
parent d7b9889b4a
commit 3b8790cc04

View File

@ -5,22 +5,20 @@
|% |%
+$ card card:agent:gall +$ card card:agent:gall
+$ versioned-state +$ versioned-state
$% state-zero $% state-0
state-one state-1
state-two state-2
state-three
== ==
:: ::
+$ state-zero [%0 =inbox:store] +$ state-0 [%0 =inbox:store]
+$ state-one [%1 =inbox:store] +$ state-1 [%1 =inbox:store]
+$ state-two [%2 =inbox:store] +$ state-2 [%2 =inbox:store]
+$ state-three [%3 =inbox:store]
+$ admin-action +$ admin-action
$% [%trim ~] $% [%trim ~]
== ==
-- --
:: ::
=| state-three =| state-2
=* state - =* state -
:: ::
%- agent:dbug %- agent:dbug
@ -38,19 +36,25 @@
++ on-save !>(state) ++ on-save !>(state)
++ on-load ++ on-load
|= old-vase=vase |= old-vase=vase
^- (quip card _this)
|^
=/ old !<(versioned-state old-vase) =/ old !<(versioned-state old-vase)
?: ?=(%3 -.old) =? old ?=(%0 -.old)
[~ this(state old)] (old-to-2 inbox.old)
?: ?=(%2 -.old) =? old ?=(%1 -.old)
:_ this(state [%3 inbox.old]) (old-to-2 inbox.old)
[%pass /trim %agent [our.bowl %chat-store] %poke %noun !>([%trim ~])]~ :_ this(state [%2 inbox.old])
=/ reversed-inbox=inbox:store [%pass /trim %agent [our.bowl %chat-store] %poke %noun !>([%trim ~])]~
%- ~(run by inbox.old) ::
++ old-to-2
|= =inbox:store
^- state-2
:- %2
%- ~(run by inbox)
|= =mailbox:store |= =mailbox:store
^- mailbox:store ^- mailbox:store
[config.mailbox (flop envelopes.mailbox)] [config.mailbox (flop envelopes.mailbox)]
:_ this(state [%3 reversed-inbox]) --
[%pass /trim %agent [our.bowl %chat-store] %poke %noun !>([%trim ~])]~
:: ::
++ on-poke ++ on-poke
~/ %chat-store-poke ~/ %chat-store-poke
@ -61,7 +65,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 (poke-noun:cc !<(admin-action vase)) %noun [~ (poke-noun:cc !<(admin-action vase))]
== ==
[cards this] [cards this]
:: ::
@ -160,28 +164,29 @@
:: ::
++ poke-noun ++ poke-noun
|= nou=admin-action |= nou=admin-action
^- (quip card _state) ^- _state
~& %trimming-chat-store ~& %trimming-chat-store
:- ~ %_ state
:- %3 inbox
%- ~(urn by inbox) %- ~(urn by inbox)
|= [=path mailbox:store] |= [=path mailbox:store]
^- mailbox:store ^- mailbox:store
=/ [a=* out=(list envelope:store)] =/ [a=* out=(list envelope:store)]
%+ roll envelopes %+ roll envelopes
|= $: =envelope:store |= $: =envelope:store
o=[[hav=(set serial:store) curr=@] out=(list envelope:store)] o=[[hav=(set serial:store) curr=@] out=(list envelope:store)]
== ==
?: (~(has in hav.o) uid.envelope) ?: (~(has in hav.o) uid.envelope)
[[hav.o curr.o] out.o] [[hav.o curr.o] out.o]
:- :-
^- [(set serial:store) @] ^- [(set serial:store) @]
[(~(put in hav.o) uid.envelope) +(curr.o)] [(~(put in hav.o) uid.envelope) +(curr.o)]
^- (list envelope:store) ^- (list envelope:store)
[envelope(number curr.o) out.o] [envelope(number curr.o) out.o]
=/ len (lent out) =/ len (lent out)
~& [path [%old (lent envelopes)] [%new len]] ~& [path [%old (lent envelopes)] [%new len]]
[[len len] (flop out)] [[len len] (flop out)]
==
:: ::
++ poke-json ++ poke-json
|= jon=json |= jon=json