changed state and mark structures of api, filled out some logic

This commit is contained in:
Isaac Visintainer 2018-11-21 11:26:43 -08:00
parent a0c2157483
commit 6f85f58464
4 changed files with 103 additions and 73 deletions

View File

@ -217,14 +217,7 @@
%circles
?> ?=(%circles -.piz)
=/ noms=(set name:hall) (~(dif in cis.piz) (sy ~[%inbox %i %public]))
=/ circs=(map circle:hall (unit config:hall))
^- (map circle:hall (unit config:hall))
%- ~(rep in noms)
|= [n=name:hall out=(map circle:hall (unit config:hall))]
^- (map circle:hall (unit config:hall))
(~(put by out) [[our.bol n] ~])
::
:_ this(our-circles.str.sta (~(uni in our-circles.str.sta) circs))
:_ this(our-circles.str.sta (~(uni in our-circles.str.sta) noms))
^- (list move)
%+ turn ~(tap in noms)
|= nom=name:hall
@ -236,10 +229,15 @@
%inbox
?> ?=(%circle -.piz)
:- ~
%= this
con.inbox.str.sta `loc.cos.piz
env.inbox.str.sta nes.piz
sub-circles.str.sta (~(run by rem.cos.piz) |=(a=config:hall `a))
%= this
con.inbox.str.sta `loc.cos.piz
::
env.inbox.str.sta nes.piz
::
circles.str.sta
%- ~(uni in circles.str.sta)
^- (map circle:hall (unit config:hall))
(~(run by rem.cos.piz) |=(a=config:hall `a))
==
::
:: %invites: fill invite messages with prize data
@ -256,10 +254,14 @@
%our
?> ?=(%circle -.piz)
=/ nom=name:hall &2:wir
:: XX todo: send rumor or let config-change handle it?
::
:- ~
%= this
our-circles.str.sta
(~(put by our-circles.str.sta) [our.bol nom] `loc.cos.piz)
%= this
circles.str.sta
(~(put by circles.str.sta) [our.bol nom] `loc.cos.piz)
::
our-circles.str.sta (~(put in our-circles.str.sta) nom)
==
==
::
@ -277,32 +279,35 @@
:: %circles:
::
%circles
~& %circles
?> ?=(%circles -.rum)
=/ circ=circle:hall [our.bol cir.rum]
?: add.rum
:_ this(our-circles.str.sta (~(put by our-circles.str.sta) circ ~))
:_ this(our-circles.str.sta (~(put in our-circles.str.sta) cir.rum))
[ost.bol %peer /our/[cir.rum] [our.bol %hall] /circle/[cir.rum]/config]~
:_ this(our-circles.str.sta (~(del by our-circles.str.sta) circ))
:- [ost.bol %pull /our/[cir.rum] [our.bol %hall] ~]
(send-rumor %circle-change %our circ ~)
:_ this(our-circles.str.sta (~(del in our-circles.str.sta) cir.rum))
[ost.bol %pull /our/[cir.rum] [our.bol %hall] ~]~
::
:: %inbox:
::
%inbox
?> ?=(%circle -.rum)
?+ -.rum.rum
~& unprocessed-rumor+rum.rum
~& inbox-unprocessed-rumor+rum.rum
[~ this]
::
:: %remove:
::
%remove
~& %inbox-remove
~& %removed-story
[~ this]
::
:: %gram: inbox has recieved messages
::
%gram
~& %inbox-gram
:: XX TODO: handle stack trace message when foreign circle is killed?
::
:- (send-rumor [%new-msg %inbox nev.rum.rum])
this(env.inbox.str.sta [nev.rum.rum env.inbox.str.sta])
::
@ -311,45 +316,67 @@
%config
=* circ cir.rum.rum
?+ -.dif.rum.rum
~& unprocessed-config+dif.rum.rum
~& inbox-unprocessed-config+dif.rum.rum
[~ this]
::
:: %remove: circle has been erased
::
%remove
~& %inbox-config-remove
:- (send-rumor %config-change cir.rum.rum ~)
%= this
circles.str.sta
(~(del by circles.str.sta) cir.rum.rum)
==
::
:: %source: the sources of our inbox have changed
::
%source
~& %inbox-config-source
?. =(circ [our.bol %inbox])
[~ this]
:: we've added a source to our inbox
::
?> ?=(^ con.inbox.str.sta)
?: add.dif.rum.rum
?> ?=(^ con.inbox.str.sta)
=/ conf=config:hall
%= u.con.inbox.str.sta
src
(~(put by src.u.con.inbox.str.sta) src.dif.rum.rum)
src (~(put in src.u.con.inbox.str.sta) src.dif.rum.rum)
==
:- (send-rumor %circle-change %our [our.bol %inbox] `conf)
%= this
con.inbox.str.sta `conf
:- (send-rumor %config-change [our.bol %inbox] `conf)
%= this
con.inbox.str.sta `conf
::
sub-circles.str.sta
(~(put by sub-circles.str.sta) cir.src.dif.rum.rum ~)
circles.str.sta
?: (~(has by circles.str.sta) cir.src.dif.rum.rum)
circles.str.sta
(~(put by circles.str.sta) cir.src.dif.rum.rum ~)
==
:: we've removed a source from our inbox
::
:- (send-rumor %circle-change %sub cir.src.dif.rum.rum ~)
%= this
sub-circles.str.sta
(~(del by sub-circles.str.sta) cir.src.dif.rum.rum)
=/ conf=config:hall
%= u.con.inbox.str.sta
src (~(del in src.u.con.inbox.str.sta) src.dif.rum.rum)
==
~& inbox+conf
:- (send-rumor %config-change [our.bol %inbox] `conf)
%= this
con.inbox.str.sta `conf
::
circles.str.sta
?: =(our.bol hos.cir.src.dif.rum.rum)
circles.str.sta
(~(del by circles.str.sta) cir.src.dif.rum.rum)
==
::
:: %full: recieved a full config update for one of our sources
::
%full
~& %inbox-config-full
=* conf cof.dif.rum.rum
:- (send-rumor %circle-change %sub circ `conf)
:- (send-rumor %config-change circ `conf)
%= this
sub-circles.str.sta (~(put by sub-circles.str.sta) circ `conf)
circles.str.sta (~(put by circles.str.sta) circ `conf)
==
==
==
@ -357,6 +384,7 @@
:: %invites:
::
%invites
~& %invites
?> ?=(%circle -.rum)
?> ?=(%gram -.rum.rum)
:- (send-rumor [%new-msg %invites nev.rum.rum])
@ -367,13 +395,13 @@
%our
?> ?=(%circle -.rum)
?+ -.rum.rum
~& unprocessed-rumor+rum.rum
~& our-unprocessed-rumor+rum.rum
[~ this]
::
:: %remove:
::
%remove
~& %removed-story
~& %our-remove
[~ this]
::
:: %config:
@ -382,16 +410,17 @@
=* circ cir.rum.rum
=* diff dif.rum.rum
?+ -.diff
~& unprocessed-config+diff
~& our-unprocessed-config+diff
[~ this]
::
:: %full: recieved a full config update for one of our sources
::
%full
~& %our-config-full
=* conf cof.dif.rum.rum
:- (send-rumor %circle-change %our circ `conf)
:- (send-rumor %config-change circ `conf)
%= this
our-circles.str.sta (~(put by our-circles.str.sta) circ `conf)
circles.str.sta (~(put by circles.str.sta) circ `conf)
==
==
==
@ -401,8 +430,9 @@
::
++ send-rumor
|= rum=rumor
~& send-rumor+rum
^- (list move)
%+ turn (prey:pubsub:userlib /data bol)
%+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *]
[bone %diff %collections-rumor rum]
::

View File

@ -4,8 +4,7 @@
/? 309
/- hall
/+ cram, elem-to-react-json
::
::
:: ::
~% %collections-lib ..is ~
|%
+$ move [bone card]
@ -22,6 +21,7 @@
+$ diff
$% [%collections-prize prize]
[%collections-rumor rumor]
[%hall-rumor rumor:hall]
==
::
+$ poke
@ -35,30 +35,30 @@
==
::
+$ streams
$: :: inbox config and the last 30 messages in it
$: :: inbox config and messages
::
inbox=[con=(unit config:hall) env=(list envelope:hall)]
:: names and configs of all circles we own
:: names and configs of all circles we know about
::
our-circles=(map circle:hall (unit config:hall))
:: names and configs of all circles we're subscribed to
circles=(map circle:hall (unit config:hall))
:: names of all circles we own
::
sub-circles=(map circle:hall (unit config:hall))
our-circles=(set name:hall)
:: all the DM invites we've received
::
invites=(list envelope:hall)
==
::
+$ prize
$: :: inbox config and the last 30 messages in it
$: :: inbox config and messages
::
inbox=[con=(unit config:hall) env=(list envelope:hall)]
:: names and configs of all circles we own
:: names and configs of all circles we know about
::
our-circles=(map circle:hall (unit config:hall))
:: names and configs of all circles we're subscribed to
circles=(map circle:hall (unit config:hall))
:: names of all circles we own
::
sub-circles=(map circle:hall (unit config:hall))
our-circles=(set name:hall)
:: all the DM invites we've received
::
invites=(list envelope:hall)
@ -68,7 +68,7 @@
$% :: if config is given, either add new circle or update existing one
:: if config is nil then delete circle
::
[%circle-change wit=?(%our %sub) cir=circle:hall con=(unit config:hall)]
[%config-change cir=circle:hall con=(unit config:hall)]
:: recieved a new inbox message or DM invite
::
[%new-msg nom=?(%inbox %invites) env=envelope:hall]
@ -611,7 +611,7 @@
%^ ta-hall-json parent-path 'new collection'
(collection-notify pax meta.col.new)
::
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=. ta-this (ta-hall-create-circle pax name.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
|-
?~ items ta-this
@ -619,7 +619,7 @@
$(items t.items)
::
%both
=. ta-this (ta-hall-create-circle pax description.meta.col.new)
=. ta-this (ta-hall-create-circle pax name.meta.col.new)
=/ items=(list [nom=@ta =item]) ~(tap by data.col.new)
=. ta-this
|-
@ -940,7 +940,7 @@
::
++ ta-hall-create-circle
~/ %coll-ta-hall-create-circle
|= [pax=path description=@t]
|= [pax=path name=@t]
^+ ta-this
=/ circ=circle:hall (path-to-circle pax our.bol)
=/ parent=circle:hall
@ -948,7 +948,7 @@
[our.bol %inbox]
(path-to-circle (scag (dec (lent pax)) pax) our.bol)
%- ta-hall-actions
:~ [%create nom.circ description %journal]
:~ [%create nom.circ name %journal]
[%source nom.parent & (sy `source:hall`[circ ~] ~)]
==
::

View File

@ -11,28 +11,27 @@
++ json
=, enjs:format
^- ^json
%+ frond %landscape
%+ frond %prize
%- pairs
:~ :- %inbox
%- pairs
:~ [%config ?~(con.inbox.piz ~ (conf:enjs:hall-json u.con.inbox.piz))]
[%envelopes %a (turn env.inbox.piz enve:enjs:hall-json)]
[%messages %a (turn env.inbox.piz enve:enjs:hall-json)]
==
::
:+ %our-circles %a
%+ turn ~(tap by our-circles.piz)
:+ %circles %a
%+ turn ~(tap by circles.piz)
|= [cir=circle:hall con=(unit config:hall)]
%- pairs
:~ [%circle (circ:enjs:hall-json cir)]
[%config ?~(con ~ (conf:enjs:hall-json u.con))]
==
::
:+ %sub-circles %a
%+ turn ~(tap by our-circles.piz)
|= [cir=circle:hall con=(unit config:hall)]
%- pairs
:~ [%circle (circ:enjs:hall-json cir)]
[%config ?~(con ~ (conf:enjs:hall-json u.con))]
==
:+ %circles-our %a
%+ turn ~(tap in our-circles.piz)
|= nom=name:hall
[%s nom]
::
[%invites %a (turn invites.piz enve:enjs:hall-json)]
==

View File

@ -10,19 +10,20 @@
++ json
=, enjs:format
^- ^json
%+ frond %landscape
%+ frond %rumor
%+ frond -.rum
?- -.rum
%circle-change
%config-change
%- pairs
:~ [%which [%s wit.rum]]
[%circle (circ:enjs:hall-json cir.rum)]
:~ [%circle (circ:enjs:hall-json cir.rum)]
[%config ?~(con.rum ~ (conf:enjs:hall-json u.con.rum))]
==
::
%new-msg
%- pairs
:~ [%circle [%s nom.rum]]
[%envelope (enve:enjs:hall-json env.rum)]
[%message (enve:enjs:hall-json env.rum)]
==
==