From 19b71d02b4ebc62eb804fdc172ebd8d6b869a794 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 14 Aug 2019 11:09:02 -0700 Subject: [PATCH 1/5] Added fixes to chat style as per Mark's comments --- pkg/arvo/app/chat.hoon | 753 ++++++++++++++++++++--------------------- pkg/arvo/lib/chat.hoon | 2 + 2 files changed, 364 insertions(+), 391 deletions(-) diff --git a/pkg/arvo/app/chat.hoon b/pkg/arvo/app/chat.hoon index 3b756d7b3..173bdce14 100644 --- a/pkg/arvo/app/chat.hoon +++ b/pkg/arvo/app/chat.hoon @@ -28,13 +28,6 @@ /| /css/ /~ ~ == -/= style - /^ octs - /; as-octs:mimes:html - /: /===/app/chat/css/index - /| /css/ - /~ ~ - == /= chat-png /^ (map knot @) /: /===/app/chat/img /_ /png/ @@ -42,6 +35,7 @@ =, chat :: |% +:: +$ state $% [%0 str=streams] == @@ -58,93 +52,59 @@ [%pull wire dock ~] [%diff diff] == +:: -- :: -|_ [bol=bowl:gall sta=state] +|_ [bol=bowl:gall state] :: ++ this . :: -:: +prep: set up the app, migrate the state once started +:: +prep: set up the app, migrate the state :: ++ prep |= old=(unit state) ^- (quip move _this) - =/ launcha/poke - [%launch-action [%chat /chattile '/~chat/js/tile.js']] + =/ launcha (launch-poke [/chattile '/~chat/js/tile.js']) ?~ old - =/ inboxpat /circle/inbox/config/group + =/ peer-inbox + %+ hall-peer + /circle/[(scot %p our.bol)]/inbox/config/group + /circle/inbox/config/group =/ circlespat /circles/[(scot %p our.bol)] - =/ inboxwir /circle/[(scot %p our.bol)]/inbox/config/group - =/ inboxi/poke - :- %hall-action - [%source %inbox %.y (silt [[our.bol %i] ~]~)] - =/ fakeannounce=poke - :- %hall-action - [%create %hall-internal-announcements '' %village] - =/ announce=poke - :- %hall-action - [%create %announcements 'Announcements from Tlon' %journal] - =/ help=poke - :- %hall-action - [%create %urbit-help 'Get help about Urbit' %channel] - =/ dev=poke - :- %hall-action - [%create %urbit-dev 'Chat about developing on Urbit' %channel] - =/ sourcefakeannounce/poke - :- %hall-action - [%source %inbox %.y (silt [[our.bol %hall-internal-announcements] ~]~)] - =/ sourceannounce/poke - :- %hall-action - [%source %inbox %.y (silt [[~marzod %announcements] ~]~)] - =/ hallactions=(list move) + =/ sourceannounce (hall-source [~marzod %announcements]) + :: + =/ hall-actions=(list move) ?: =((clan:title our.bol) %czar) ~ ?: =(our.bol ~marzod) - ~& %marzod-chat - :- [ost.bol %poke /announce [our.bol %hall] announce] - [ost.bol %poke /announce [our.bol %hall] sourceannounce]~ + :- (hall-create %announcements 'Announcements from Tlon' %journal) + [sourceannounce]~ ?: =(our.bol ~dopzod) - ~& %dopzod-chat - :- [ost.bol %poke /announce [our.bol %hall] dev] - [ost.bol %poke /announce [our.bol %hall] help]~ - :- [ost.bol %poke /announce [our.bol %hall] fakeannounce] - :- [ost.bol %poke /announce [our.bol %hall] sourcefakeannounce] - [ost.bol %poke /announce [our.bol %hall] sourceannounce]~ - =/ moves=(list move) - :~ [ost.bol %peer inboxwir [our.bol %hall] inboxpat] - [ost.bol %peer circlespat [our.bol %hall] circlespat] - [ost.bol %connect / [~ /'~chat'] %chat] - [ost.bol %poke /chat [our.bol %hall] inboxi] - [ost.bol %poke /chat [our.bol %launch] launcha] - == + :- (hall-create %urbit-dev 'Chat about developing on Urbit' %channel) + [(hall-create %urbit-help 'Help about Urbit' %channel)]~ + :~ (hall-create %hall-internal-announcements '' %village) + (hall-source [our.bol %hall-internal-announcements]) + sourceannounce + == + :: + =/ actions=(list move) + :~ [ost.bol %connect / [~ /'~chat'] %chat] + launcha + peer-inbox + (hall-peer circlespat circlespat) + (hall-source [our.bol %i]) + == :_ this - %+ weld moves hallactions - :- [ost.bol %poke /chat [our.bol %launch] launcha]~ - this(sta u.old) -:: -++ construct-tile-json - |= str=streams - ^- json - =/ numbers/(list [circle:hall @ud]) - %+ turn ~(tap by messages.str) - |= [cir=circle:hall lis=(list envelope:hall)] - ^- [circle:hall @ud] - ?~ lis - [cir 0] - =/ last (snag (dec (lent lis)) `(list envelope:hall)`lis) - [cir (add num.last 1)] - =/ maptjson=(map @t json) - %- my - :~ ['config' (config-to-json str)] - ['numbers' (numbers-to-json numbers)] - == - [%o maptjson] + (weld actions hall-actions) + :: + :_ this(+<+ u.old) + [launcha]~ :: ++ peer-chattile |= wir=wire ^- (quip move _this) :_ this - [ost.bol %diff %json (construct-tile-json str.sta)]~ + [ost.bol %diff %json (construct-tile-json str)]~ :: :: +peer-messages: subscribe to subset of messages and updates :: @@ -152,12 +112,12 @@ ++ peer-primary |= wir=wire ^- (quip move _this) - =* messages messages.str.sta - =/ lismov/(list move) + =* messages messages.str + =/ lismov=(list move) %+ murn ~(tap by messages) |= [cir=circle:hall lis=(list envelope:hall)] ^- (unit move) - =/ envs/(unit (list envelope:hall)) (~(get by messages) cir) + =/ envs=(unit (list envelope:hall)) (~(get by messages) cir) ?~ envs ~ =/ length/@ (lent u.envs) @@ -174,7 +134,7 @@ [%messages cir start end (swag [start offset] u.envs)] == :_ this - [[ost.bol %diff %chat-config str.sta] lismov] + [[ost.bol %diff %chat-config str] lismov] :: :: +poke-chat: send us an action :: @@ -183,34 +143,14 @@ ^- (quip move _this) :_ this %+ turn lis.act - |= hac=action:hall - ^- move - :* ost.bol - %poke - /p/[(scot %da now.bol)] - [our.bol %hall] - [%hall-action hac] - == -:: -:: +send-chat-update: utility func for sending updates to all our subscribers -:: -++ send-chat-update - |= [upd=update str=streams] - ^- (list move) - =/ updates/(list move) - %+ turn (prey:pubsub:userlib /primary bol) - |= [=bone *] - [bone %diff %chat-update upd] - :: - =/ jon/json (construct-tile-json str) - =/ tile-updates/(list move) - %+ turn (prey:pubsub:userlib /chattile bol) - |= [=bone *] - [bone %diff %json jon] - :: - %+ weld - updates - tile-updates + |= hac=action:hall + ^- move + :* ost.bol + %poke + /p/[(scot %da now.bol)] + [our.bol %hall] + [%hall-action hac] + == :: :: :: +hall arms @@ -225,109 +165,86 @@ (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) ?+ i.wir (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) + :: + :: %circles wire + :: + %circles + ?> ?=(%circles -.piz) + :_ this(circles.str cis.piz) + (send-chat-update [[%circles cis.piz] str]) + :: + :: %circle wire + :: + %circle + ?> ?=(%circle -.piz) + =/ circle/circle:hall [our.bol &3:wir] + :: + :: fill inbox config and remote configs with prize data + :: + ?: =(circle [our.bol %inbox]) + =/ configs + %- ~(uni in configs.str) + ^- (map circle:hall (unit config:hall)) + (~(run by rem.cos.piz) |=(a=config:hall `a)) :: - :: %circles wire + =/ circles=(list circle:hall) + (turn ~(tap in src.loc.cos.piz) head) :: - %circles - ?> ?=(%circles -.piz) - =/ str %= str.sta - circles cis.piz + =/ meslis=(list [circle:hall (list envelope:hall)]) + %+ turn circles + |= cir=circle:hall + ^- [circle:hall (list envelope:hall)] + [cir ~] + :: + =/ localpeers=(set @p) + (silt (turn ~(tap by loc.pes.piz) head)) + :: + =/ peers/(map circle:hall (set @p)) + %- ~(rep by rem.pes.piz) + |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] + ^- (map circle:hall (set @p)) + (~(put by acc) cir (silt (turn ~(tap by grp) head))) + :: + :- + %+ turn ~(tap in (~(del in (silt circles)) [our.bol %inbox])) + |= cir=circle:hall + ^- move + =/ wir/wire /circle/[(scot %p our.bol)]/[nom.cir]/config/group + =/ pat/path /circle/[nom.cir]/config/group + [ost.bol %peer wir [our.bol %hall] pat] + :: + %= this + inbox.str loc.cos.piz + configs.str configs + messages.str (molt meslis) + peers.str (~(put by peers) [our.bol %inbox] localpeers) + == + :: + :: fill remote configs with message data + :: + =* messages messages.str + =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] + =/ localpeers=(set @p) (silt (turn ~(tap by loc.pes.piz) head)) + :: + =/ peers=(map circle:hall (set @p)) + %- ~(rep by rem.pes.piz) + |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] + ^- (map circle:hall (set @p)) + (~(put by acc) cir (silt (turn ~(tap by grp) head))) + =/ str + %= str + messages (~(put by messages) circle nes.piz) + peers (~(uni by peers.str) (~(put by peers) circle localpeers)) == - :- (send-chat-update [[%circles cis.piz] str]) - this(str.sta str) - :: - :: %circle wire - :: - %circle -:: :: -:: :: %circle prize -:: :: -:: %circle - ?> ?=(%circle -.piz) - =/ circle/circle:hall [our.bol &3:wir] - ?: =(circle [our.bol %inbox]) - :: - :: fill inbox config and remote configs with prize data - :: - =/ configs - %- ~(uni in configs.str.sta) - ^- (map circle:hall (unit config:hall)) - (~(run by rem.cos.piz) |=(a=config:hall `a)) - :: - =/ circles/(list circle:hall) - %+ turn ~(tap in src.loc.cos.piz) - |= src=source:hall - ^- circle:hall - cir.src - :: - =/ meslis/(list [circle:hall (list envelope:hall)]) - %+ turn circles - |= cir=circle:hall - ^- [circle:hall (list envelope:hall)] - [cir ~] - :: - =/ localpeers/(set @p) - %- silt %+ turn ~(tap by loc.pes.piz) - |= [shp=@p stat=status:hall] - shp - :: - =/ peers/(map circle:hall (set @p)) - %- ~(rep by rem.pes.piz) - |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] - ^- (map circle:hall (set @p)) - =/ newset - %- silt %+ turn ~(tap by grp) - |= [shp=@p stat=status:hall] - shp - (~(put by acc) cir newset) - :: - :- - %+ turn ~(tap in (~(del in (silt circles)) [our.bol %inbox])) - |= cir=circle:hall - ^- move - =/ wir/wire /circle/[(scot %p our.bol)]/[nom.cir]/config/group - =/ pat/path /circle/[nom.cir]/config/group - [ost.bol %peer wir [our.bol %hall] pat] - :: - %= this - inbox.str.sta loc.cos.piz - configs.str.sta configs - messages.str.sta (molt meslis) - peers.str.sta (~(put by peers) [our.bol %inbox] localpeers) - == - :: - :: fill remote configs with message data - :: - =* messages messages.str.sta - =/ circle/circle:hall [`@p`(slav %p &2:wir) &3:wir] - =/ localpeers/(set @p) - %- silt %+ turn ~(tap by loc.pes.piz) - |= [shp=@p stat=status:hall] - shp - :: - =/ peers/(map circle:hall (set @p)) - %- ~(rep by rem.pes.piz) - |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] - ^- (map circle:hall (set @p)) - =/ newset - %- silt %+ turn ~(tap by grp) - |= [shp=@p stat=status:hall] - shp - (~(put by acc) cir newset) - =/ str - %= str.sta - messages (~(put by messages) circle nes.piz) - peers (~(uni by peers.str.sta) (~(put by peers) circle localpeers)) - == - =/ messageupdate/update - :* %messages - circle - 0 - (lent messages) - nes.piz - == - :- (send-chat-update [messageupdate str]) - this(str.sta str) + =/ messageupdate=update + :* %messages + circle + 0 + (lent messages) + nes.piz + == + :- (send-chat-update [messageupdate str]) + this(str str) == :: :: +diff-hall-rumor: handle updates to hall state @@ -341,195 +258,188 @@ (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: :: %circles - %circles - ?> ?=(%circles -.rum) - =/ cis + :: + %circles + ?> ?=(%circles -.rum) + =/ cis + ?: add.rum + (~(put in circles.str) cir.rum) + (~(del in circles.str) cir.rum) + =/ sta + %= str + circles cis + peers ?: add.rum - (~(put in circles.str.sta) cir.rum) - (~(del in circles.str.sta) cir.rum) - =/ str - %= str.sta - circles cis - peers - ?: add.rum - (~(put by peers.str.sta) [our.bol cir.rum] ~) - (~(del by peers.str.sta) [our.bol cir.rum]) - == - :- (send-chat-update [[%circles cis] str]) - this(str.sta str) + (~(put by peers.str) [our.bol cir.rum] ~) + (~(del by peers.str) [our.bol cir.rum]) + == + :_ this(str sta) + (send-chat-update [[%circles cis] sta]) :: :: :: %circle: fill remote configs with message data :: - %circle - ?> ?=(%circle -.rum) - =* sto rum.rum - ?+ -.sto - [~ this] - :: - :: %gram: - :: - %gram - ?> ?=(%gram -.sto) - =* messages messages.str.sta - =/ circle/circle:hall [`@p`(slav %p &2:wir) &3:wir] - =/ unes/(unit (list envelope:hall)) (~(get by messages) circle) - ?~ unes - [~ this] - =/ nes u.unes - =/ str - %= str.sta - messages (~(put by messages) circle (snoc nes nev.sto)) - == - :- (send-chat-update [[%message circle nev.sto] str]) - this(str.sta str) - :: - :: %status: - :: - %status - ?> ?=(%status -.sto) - =/ upeers/(unit (set @p)) (~(get by peers.str.sta) cir.sto) - ?~ upeers - [~ this] - =/ peers/(set @p) - ?: =(%remove -.dif.sto) - (~(del in u.upeers) who.sto) - (~(put in u.upeers) who.sto) - =/ str - %= str.sta - peers (~(put by peers.str.sta) cir.sto peers) - == - :- (send-chat-update [[%peers cir.sto peers] str]) - this(str.sta str) - :: - :: %config: config has changed - :: - %config - =* circ cir.sto - :: - ?+ -.dif.sto - [~ this] - :: - :: %full: set all of config without side effects - :: - %full - =* conf cof.dif.sto - =/ str - %= str.sta - configs (~(put by configs.str.sta) circ `conf) - == - :- (send-chat-update [[%config circ conf] str]) - this(str.sta str) - :: - :: %read: the read count of one of our configs has changed - :: - %read - ?: =(circ [our.bol %inbox]) - :: ignore when circ is inbox - [~ this] - =/ uconf/(unit config:hall) (~(got by configs.str.sta) circ) - ?~ uconf - :: should we crash? - [~ this] - =/ conf/config:hall - %= u.uconf - red red.dif.sto - == - =/ str - %= str.sta - configs (~(put by configs.str.sta) circ `conf) - == - :- (send-chat-update [[%config circ conf] str]) - this(str.sta str) - :: - :: %source: the sources of our inbox have changed - :: - %source - ?. =(circ [our.bol %inbox]) - :: ignore when circ is not inbox - [~ this] - =* affectedcir cir.src.dif.sto - =/ newwir/wire - /circle/[(scot %p hos.affectedcir)]/[nom.affectedcir]/grams/0/config/group - =/ pat/path /circle/[nom.affectedcir]/grams/0/config/group - :: we've added a source to our inbox - :: - ?: add.dif.sto - =/ newinbox %= inbox.str.sta - src (~(put in src.inbox.str.sta) src.dif.sto) - == - =/ str - %= str.sta - inbox newinbox - :: - configs - ?: (~(has by configs.str.sta) affectedcir) - configs.str.sta - (~(put by configs.str.sta) affectedcir ~) - == - :: - :_ this(str.sta str) - %+ weld - [ost.bol %peer newwir [hos.affectedcir %hall] pat]~ - (send-chat-update [[%inbox newinbox] str]) - :: - =/ newinbox %= inbox.str.sta - src (~(del in src.inbox.str.sta) src.dif.sto) - == - :: we've removed a source from our inbox - :: - =/ str - %= str.sta - inbox newinbox - :: - configs (~(del by configs.str.sta) affectedcir) - messages (~(del by messages.str.sta) affectedcir) - peers (~(del by peers.str.sta) affectedcir) - == - =/ fakecir/circle:hall - :- our.bol - %- crip - %+ weld (trip 'hall-internal-') (trip nom.affectedcir) - :: - ?~ (~(get by configs.str) fakecir) - :: just forward the delete to our clients - :: - :_ this(str.sta str) - %+ weld - [ost.bol %pull newwir [hos.affectedcir %hall] ~]~ - %+ weld - (send-chat-update [[%inbox newinbox] str]) - (send-chat-update [[%delete affectedcir] str]) - :: if we get a delete from another ship, delete our fake circle copy - :: - =/ deletefake/poke - :- %hall-action - [%delete nom.fakecir ~] - :_ this(str.sta str) - %+ weld - [ost.bol %pull newwir [hos.affectedcir %hall] ~]~ - %+ weld - [ost.bol %poke /fake [our.bol %hall] deletefake]~ - %+ weld - (send-chat-update [[%inbox newinbox] str]) - (send-chat-update [[%delete affectedcir] str]) - :: - :: %remove: remove a circle - :: - %remove - =/ str - %= str.sta - configs (~(del by configs.str.sta) circ) - messages (~(del by messages.str.sta) circ) - peers (~(del by peers.str.sta) circ) - == - :- (send-chat-update [[%delete circ] str]) - this(str.sta str) - :: - == - :: end of branching on dif.sto type + %circle + ?> ?=(%circle -.rum) + =* sto rum.rum + ?+ -.sto + [~ this] + :: + :: %gram: + :: + %gram + ?> ?=(%gram -.sto) + =* messages messages.str + =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] + =/ nes=(unit (list envelope:hall)) (~(get by messages) circle) + ?~ nes + [~ this] + =/ sta + %= str + messages (~(put by messages) circle (snoc u.nes nev.sto)) == - :: end of branching on sto type + :_ this(str sta) + (send-chat-update [[%message circle nev.sto] sta]) + :: + :: status: + :: + %status + ?> ?=(%status -.sto) + =/ upeers=(unit (set @p)) (~(get by peers.str) cir.sto) + ?~ upeers + [~ this] + =/ peers=(set @p) + ?: =(%remove -.dif.sto) + (~(del in u.upeers) who.sto) + (~(put in u.upeers) who.sto) + =/ sta + %= str + peers (~(put by peers.str) cir.sto peers) + == + :_ this(str sta) + (send-chat-update [[%peers cir.sto peers] sta]) + :: + :: %config: config has changed + :: + %config + =* circ cir.sto + :: + ?+ -.dif.sto + [~ this] + :: + :: %full: set all of config without side effects + :: + %full + =* conf cof.dif.sto + =/ sta + %= str + configs (~(put by configs.str) circ `conf) + == + :_ this(str sta) + (send-chat-update [[%config circ conf] sta]) + :: + :: %read: the read count of one of our configs has changed + :: + %read + ?: =(circ [our.bol %inbox]) + :: ignore when circ is inbox + [~ this] + =/ uconf/(unit config:hall) (~(got by configs.str) circ) + ?~ uconf + [~ this] + =/ conf/config:hall + %= u.uconf + red red.dif.sto + == + =/ sta + %= str + configs (~(put by configs.str) circ `conf) + == + :_ this(str sta) + (send-chat-update [[%config circ conf] sta]) + :: + :: %source: the sources of our inbox have changed + :: + %source + ?. =(circ [our.bol %inbox]) + :: ignore when circ is not inbox + [~ this] + =* affectedcir cir.src.dif.sto + =/ newwir/wire + /circle/(scot %p hos.affectedcir)/[nom.affectedcir]/grams/0/config/group + =/ pat/path /circle/[nom.affectedcir]/grams/0/config/group + :: we've added a source to our inbox + :: + ?: add.dif.sto + =/ newinbox %= inbox.str + src (~(put in src.inbox.str) src.dif.sto) + == + =/ sta + %= str + inbox newinbox + :: + configs + ?: (~(has by configs.str) affectedcir) + configs.str + (~(put by configs.str) affectedcir ~) + == + :: + :_ this(str sta) + %+ weld + [ost.bol %peer newwir [hos.affectedcir %hall] pat]~ + (send-chat-update [[%inbox newinbox] sta]) + :: + =/ newinbox %= inbox.str + src (~(del in src.inbox.str) src.dif.sto) + == + :: we've removed a source from our inbox + :: + =/ sta + %= str + inbox newinbox + :: + configs (~(del by configs.str) affectedcir) + messages (~(del by messages.str) affectedcir) + peers (~(del by peers.str) affectedcir) + == + =/ fakecir/circle:hall + :- our.bol + (crip (weld (trip 'hall-internal-') (trip nom.affectedcir))) + :: + ?~ (~(get by configs.str) fakecir) + :: just forward the delete to our clients + :: + :_ this(str sta) + :- [ost.bol %pull newwir [hos.affectedcir %hall] ~] + %+ weld + (send-chat-update [[%inbox newinbox] sta]) + (send-chat-update [[%delete affectedcir] sta]) + :: if we get a delete from another ship, delete our fake circle copy + :: + =/ deletefake [%hall-action [%delete nom.fakecir ~]] + :_ this(str str) + :- [ost.bol %pull newwir [hos.affectedcir %hall] ~] + :- [ost.bol %poke /fake [our.bol %hall] deletefake] + %+ weld + (send-chat-update [[%inbox newinbox] sta]) + (send-chat-update [[%delete affectedcir] sta]) + :: + :: %remove: remove a circle + :: + %remove + =/ sta + %= str + configs (~(del by configs.str) circ) + messages (~(del by messages.str) circ) + peers (~(del by peers.str) circ) + == + :- (send-chat-update [[%delete circ] sta]) + this(str sta) + :: + == + :: end of branching on dif.sto type + == + :: end of branching on sto type == :: end of i.wir branching :: @@ -587,7 +497,7 @@ =/ cir/circle:hall [(slav %p &3:site.request-line) &4:site.request-line] =/ start/@ud (need (rush &5:site.request-line dem)) =/ parsedend/@ud (need (rush &6:site.request-line dem)) - =* messages messages.str.sta + =* messages messages.str =/ envs/(unit (list envelope:hall)) (~(get by messages) cir) ?~ envs [~ this] @@ -638,7 +548,7 @@ ?: =(&3:wir 'inbox') :_ this [ost.bol %peer wir [shp %hall] pat]~ - ?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~]) + ?: (~(has in src.inbox.str) [[shp &3:wir] ~]) :_ this [ost.bol %peer wir [shp %hall] pat]~ [~ this] @@ -664,7 +574,7 @@ ?: =(&3:wir 'inbox') :_ this [ost.bol %peer wir [shp %hall] pat]~ - ?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~]) + ?: (~(has in src.inbox.str) [[shp &3:wir] ~]) :_ this [ost.bol %peer wir [shp %hall] pat]~ [~ this] @@ -674,4 +584,65 @@ [ost.bol %peer wir [our.bol %hall] wir]~ == :: +:: +utilities +:: +:: +:: +send-chat-update: utility func for sending updates to all our subscribers +:: +++ send-chat-update + |= [upd=update str=streams] + ^- (list move) + =/ updates=(list move) + %+ turn (prey:pubsub:userlib /primary bol) + |= [=bone *] + [bone %diff %chat-update upd] + :: + =/ jon (construct-tile-json str) + =/ tile-updates=(list move) + %+ turn (prey:pubsub:userlib /chattile bol) + |= [=bone *] + [bone %diff %json jon] + :: + (weld updates tile-updates) +:: +++ construct-tile-json + |= str=streams + ^- json + =/ numbers/(list [circle:hall @ud]) + %+ turn ~(tap by messages.str) + |= [cir=circle:hall lis=(list envelope:hall)] + ^- [circle:hall @ud] + ?~ lis + [cir 0] + =/ last (snag (dec (lent lis)) `(list envelope:hall)`lis) + [cir (add num.last 1)] + =/ maptjson=(map @t json) + %- my + :~ ['config' (config-to-json str)] + ['numbers' (numbers-to-json numbers)] + == + [%o maptjson] +:: +++ launch-poke + |= [=path =cord] + ^- move + [ost.bol %poke /chat [our.bol %launch] [%launch-action %chat path cord]] +:: +++ hall-peer + |= [wir=wire pat=path] + ^- move + [ost.bol %peer wir [our.bol %hall] pat] +:: +++ hall-create + |= [name=@tas description=@t =security:hall] + ^- move + =/ poke [%hall-action [%create name description security]] + [ost.bol %poke /chat [our.bol %hall] poke] +:: +++ hall-source + |= cir=circle:hall + ^- move + =/ poke [%hall-action [%source %inbox %.y (silt [cir ~]~)]] + [ost.bol %poke /chat [our.bol %hall] poke] +:: -- diff --git a/pkg/arvo/lib/chat.hoon b/pkg/arvo/lib/chat.hoon index 6bb69d594..d0bf9b57f 100644 --- a/pkg/arvo/lib/chat.hoon +++ b/pkg/arvo/lib/chat.hoon @@ -1,6 +1,8 @@ /- *chat, hall /+ hall-json |% +:: +:: ++ msg-to-json =, enjs:format |= upd=update From 7dfd796e95b7c9ea31c34f1b7f66b48e14436265 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 14 Aug 2019 16:19:24 -0700 Subject: [PATCH 2/5] Updated to remove some of the =/ with the old style, and a few other small changes --- pkg/arvo/app/chat.hoon | 47 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/pkg/arvo/app/chat.hoon b/pkg/arvo/app/chat.hoon index 173bdce14..71a0d93df 100644 --- a/pkg/arvo/app/chat.hoon +++ b/pkg/arvo/app/chat.hoon @@ -171,7 +171,7 @@ %circles ?> ?=(%circles -.piz) :_ this(circles.str cis.piz) - (send-chat-update [[%circles cis.piz] str]) + (send-chat-update [[%circles cis.piz] sta]) :: :: %circle wire :: @@ -199,7 +199,7 @@ =/ localpeers=(set @p) (silt (turn ~(tap by loc.pes.piz) head)) :: - =/ peers/(map circle:hall (set @p)) + =/ peers=(map circle:hall (set @p)) %- ~(rep by rem.pes.piz) |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] ^- (map circle:hall (set @p)) @@ -212,7 +212,6 @@ =/ wir/wire /circle/[(scot %p our.bol)]/[nom.cir]/config/group =/ pat/path /circle/[nom.cir]/config/group [ost.bol %peer wir [our.bol %hall] pat] - :: %= this inbox.str loc.cos.piz configs.str configs @@ -231,20 +230,14 @@ |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] ^- (map circle:hall (set @p)) (~(put by acc) cir (silt (turn ~(tap by grp) head))) - =/ str + =/ sta %= str messages (~(put by messages) circle nes.piz) peers (~(uni by peers.str) (~(put by peers) circle localpeers)) == - =/ messageupdate=update - :* %messages - circle - 0 - (lent messages) - nes.piz - == - :- (send-chat-update [messageupdate str]) - this(str str) + =/ messageupdate=update [%messages circle 0 (lent messages) nes.piz] + :- (send-chat-update [messageupdate sta]) + this(str sta) == :: :: +diff-hall-rumor: handle updates to hall state @@ -402,7 +395,7 @@ messages (~(del by messages.str) affectedcir) peers (~(del by peers.str) affectedcir) == - =/ fakecir/circle:hall + =/ fakecir=circle:hall :- our.bol (crip (weld (trip 'hall-internal-') (trip nom.affectedcir))) :: @@ -417,12 +410,12 @@ :: if we get a delete from another ship, delete our fake circle copy :: =/ deletefake [%hall-action [%delete nom.fakecir ~]] - :_ this(str str) - :- [ost.bol %pull newwir [hos.affectedcir %hall] ~] - :- [ost.bol %poke /fake [our.bol %hall] deletefake] - %+ weld - (send-chat-update [[%inbox newinbox] sta]) - (send-chat-update [[%delete affectedcir] sta]) + :_ this(str sta) + :- [ost.bol %pull newwir [hos.affectedcir %hall] ~] + :- [ost.bol %poke /fake [our.bol %hall] deletefake] + %+ weld + (send-chat-update [[%inbox newinbox] sta]) + (send-chat-update [[%delete affectedcir] sta]) :: :: %remove: remove a circle :: @@ -494,21 +487,21 @@ :: paginated message data :: [%'~chat' %scroll @t @t @t @t ~] - =/ cir/circle:hall [(slav %p &3:site.request-line) &4:site.request-line] - =/ start/@ud (need (rush &5:site.request-line dem)) - =/ parsedend/@ud (need (rush &6:site.request-line dem)) + =/ cir=circle:hall [(slav %p &3:site.request-line) &4:site.request-line] + =/ start=@ud (need (rush &5:site.request-line dem)) + =/ parsedend=@ud (need (rush &6:site.request-line dem)) =* messages messages.str =/ envs/(unit (list envelope:hall)) (~(get by messages) cir) ?~ envs [~ this] ?: (gte start (lent u.envs)) [~ this] - =/ end/@ + =/ end=@ ?: (gte parsedend (lent u.envs)) (dec (lent u.envs)) parsedend =/ offset (sub end start) - =/ jon/json %- msg-to-json + =/ jon=json %- msg-to-json :* %messages cir start @@ -543,7 +536,7 @@ (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: %circle - =/ shp/@p (slav %p &2:wir) + =/ shp=@p (slav %p &2:wir) =/ pat /circle/[&3:wir]/config/group ?: =(&3:wir 'inbox') :_ this @@ -569,7 +562,7 @@ (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: %circle - =/ shp/@p (slav %p &2:wir) + =/ shp=@p (slav %p &2:wir) =/ pat /circle/[&3:wir]/config/group ?: =(&3:wir 'inbox') :_ this From 5052227ee70a5bf666288ea9c7700e658f80d13e Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 14 Aug 2019 16:32:35 -0700 Subject: [PATCH 3/5] Added more changes. --- pkg/arvo/app/chat.hoon | 76 ++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/pkg/arvo/app/chat.hoon b/pkg/arvo/app/chat.hoon index 71a0d93df..f70c51b22 100644 --- a/pkg/arvo/app/chat.hoon +++ b/pkg/arvo/app/chat.hoon @@ -87,15 +87,14 @@ sourceannounce == :: - =/ actions=(list move) - :~ [ost.bol %connect / [~ /'~chat'] %chat] - launcha - peer-inbox - (hall-peer circlespat circlespat) - (hall-source [our.bol %i]) - == :_ this - (weld actions hall-actions) + :* [ost.bol %connect / [~ /'~chat'] %chat] + launcha + peer-inbox + (hall-peer circlespat circlespat) + (hall-source [our.bol %i]) + hall-actions + == :: :_ this(+<+ u.old) [launcha]~ @@ -113,28 +112,28 @@ |= wir=wire ^- (quip move _this) =* messages messages.str - =/ lismov=(list move) - %+ murn ~(tap by messages) - |= [cir=circle:hall lis=(list envelope:hall)] - ^- (unit move) - =/ envs=(unit (list envelope:hall)) (~(get by messages) cir) - ?~ envs - ~ - =/ length/@ (lent u.envs) - =/ start/@ - ?: (gte length 100) - (sub length 100) - 0 - =/ end/@ length - =/ offset/@ (sub end start) - :- ~ - :* ost.bol - %diff - %chat-update - [%messages cir start end (swag [start offset] u.envs)] - == :_ this - [[ost.bol %diff %chat-config str] lismov] + :- [ost.bol %diff %chat-config str] + %+ murn ~(tap by messages) + |= [cir=circle:hall lis=(list envelope:hall)] + ^- (unit move) + =/ envs=(unit (list envelope:hall)) (~(get by messages) cir) + ?~ envs + ~ + =/ length/@ (lent u.envs) + =/ start/@ + ?: (gte length 100) + (sub length 100) + 0 + =/ end/@ length + =/ offset/@ (sub end start) + :- ~ + :* ost.bol + %diff + %chat-update + [%messages cir start end (swag [start offset] u.envs)] + == + :: :: +poke-chat: send us an action :: @@ -170,14 +169,18 @@ :: %circles ?> ?=(%circles -.piz) - :_ this(circles.str cis.piz) + =/ sta + %= str + circles cis.piz + == + :_ this(str sta) (send-chat-update [[%circles cis.piz] sta]) :: :: %circle wire :: %circle ?> ?=(%circle -.piz) - =/ circle/circle:hall [our.bol &3:wir] + =/ circle=circle:hall [our.bol &3:wir] :: :: fill inbox config and remote configs with prize data :: @@ -196,8 +199,7 @@ ^- [circle:hall (list envelope:hall)] [cir ~] :: - =/ localpeers=(set @p) - (silt (turn ~(tap by loc.pes.piz) head)) + =/ localpeers=(set @p) (silt (turn ~(tap by loc.pes.piz) head)) :: =/ peers=(map circle:hall (set @p)) %- ~(rep by rem.pes.piz) @@ -236,8 +238,8 @@ peers (~(uni by peers.str) (~(put by peers) circle localpeers)) == =/ messageupdate=update [%messages circle 0 (lent messages) nes.piz] - :- (send-chat-update [messageupdate sta]) - this(str sta) + :_ this(str sta) + (send-chat-update [messageupdate sta]) == :: :: +diff-hall-rumor: handle updates to hall state @@ -426,8 +428,8 @@ messages (~(del by messages.str) circ) peers (~(del by peers.str) circ) == - :- (send-chat-update [[%delete circ] sta]) - this(str sta) + :_ this(str sta) + (send-chat-update [[%delete circ] sta]) :: == :: end of branching on dif.sto type From 3ae8e55e48148961d6c6ded4ee366c5a9235cfbb Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 16 Aug 2019 11:22:19 -0700 Subject: [PATCH 4/5] Broke out functions, inlined more of the app, fewer declarations, more subject modifications rather than subject additions --- pkg/arvo/app/chat.hoon | 505 +++++++++++++++++++---------------------- pkg/arvo/lib/chat.hoon | 2 - 2 files changed, 235 insertions(+), 272 deletions(-) diff --git a/pkg/arvo/app/chat.hoon b/pkg/arvo/app/chat.hoon index f70c51b22..5c07152ac 100644 --- a/pkg/arvo/app/chat.hoon +++ b/pkg/arvo/app/chat.hoon @@ -35,7 +35,6 @@ =, chat :: |% -:: +$ state $% [%0 str=streams] == @@ -52,7 +51,6 @@ [%pull wire dock ~] [%diff diff] == -:: -- :: |_ [bol=bowl:gall state] @@ -64,40 +62,33 @@ ++ prep |= old=(unit state) ^- (quip move _this) - =/ launcha (launch-poke [/chattile '/~chat/js/tile.js']) - ?~ old - =/ peer-inbox - %+ hall-peer - /circle/[(scot %p our.bol)]/inbox/config/group - /circle/inbox/config/group - =/ circlespat /circles/[(scot %p our.bol)] - =/ sourceannounce (hall-source [~marzod %announcements]) - :: - =/ hall-actions=(list move) + ?^ old + :_ this(+<+ u.old) + [(launch-poke [/chattile '/~chat/js/tile.js'])]~ + :: + =/ inbox-path /circle/inbox/config/group + :: + :_ this + :* [ost.bol %connect / [~ /'~chat'] %chat] + (launch-poke [/chattile '/~chat/js/tile.js']) + (hall-peer /circle/(scot %p our.bol)/inbox/config/group inbox-path) + (hall-peer /circles/(scot %p our.bol) /circles/(scot %p our.bol)) + (hall-source [our.bol %i]) ?: =((clan:title our.bol) %czar) ~ ?: =(our.bol ~marzod) :- (hall-create %announcements 'Announcements from Tlon' %journal) - [sourceannounce]~ + [(hall-source [~marzod %announcements])]~ ?: =(our.bol ~dopzod) :- (hall-create %urbit-dev 'Chat about developing on Urbit' %channel) [(hall-create %urbit-help 'Help about Urbit' %channel)]~ :~ (hall-create %hall-internal-announcements '' %village) (hall-source [our.bol %hall-internal-announcements]) - sourceannounce + (hall-source [~marzod %announcements]) == - :: - :_ this - :* [ost.bol %connect / [~ /'~chat'] %chat] - launcha - peer-inbox - (hall-peer circlespat circlespat) - (hall-source [our.bol %i]) - hall-actions - == - :: - :_ this(+<+ u.old) - [launcha]~ + == +:: +:: +peer-chattile: subscribe to data necessary for chat tile :: ++ peer-chattile |= wir=wire @@ -107,7 +98,6 @@ :: :: +peer-messages: subscribe to subset of messages and updates :: -:: ++ peer-primary |= wir=wire ^- (quip move _this) @@ -115,27 +105,23 @@ :_ this :- [ost.bol %diff %chat-config str] %+ murn ~(tap by messages) - |= [cir=circle:hall lis=(list envelope:hall)] + |= [cir=circle:hall envelopes=(list envelope:hall)] ^- (unit move) - =/ envs=(unit (list envelope:hall)) (~(get by messages) cir) - ?~ envs - ~ - =/ length/@ (lent u.envs) - =/ start/@ + =/ length=@ (lent envelopes) + =/ start=@ ?: (gte length 100) (sub length 100) 0 - =/ end/@ length - =/ offset/@ (sub end start) + =/ end=@ length + =/ offset=@ (sub end start) :- ~ :* ost.bol %diff %chat-update - [%messages cir start end (swag [start offset] u.envs)] + [%messages cir start end (swag [start offset] envelopes)] == - :: -:: +poke-chat: send us an action +:: +poke-chat: send a list of actions to hall :: ++ poke-chat-action |= act=action:chat @@ -144,16 +130,7 @@ %+ turn lis.act |= hac=action:hall ^- move - :* ost.bol - %poke - /p/[(scot %da now.bol)] - [our.bol %hall] - [%hall-action hac] - == -:: -:: -:: +hall arms -:: + [ost.bol %poke /p/(scot %da now.bol) [our.bol %hall] [%hall-action hac]] :: :: +diff-hall-prize: handle full state initially handed to us by hall :: @@ -165,81 +142,68 @@ ?+ i.wir (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: - :: %circles wire + %circles + ?> ?=(%circles -.piz) + =. str str(circles cis.piz) + :_ this(str str) + (send-chat-update [[%circles cis.piz] str]) :: - %circles - ?> ?=(%circles -.piz) - =/ sta - %= str - circles cis.piz - == - :_ this(str sta) - (send-chat-update [[%circles cis.piz] sta]) - :: - :: %circle wire - :: - %circle - ?> ?=(%circle -.piz) - =/ circle=circle:hall [our.bol &3:wir] - :: - :: fill inbox config and remote configs with prize data - :: - ?: =(circle [our.bol %inbox]) - =/ configs - %- ~(uni in configs.str) - ^- (map circle:hall (unit config:hall)) - (~(run by rem.cos.piz) |=(a=config:hall `a)) + %circle + ?> ?=(%circle -.piz) + ?. =([our.bol &3:wir] [our.bol %inbox]) :: - =/ circles=(list circle:hall) - (turn ~(tap in src.loc.cos.piz) head) + :: fill remote configs with message data :: - =/ meslis=(list [circle:hall (list envelope:hall)]) - %+ turn circles - |= cir=circle:hall - ^- [circle:hall (list envelope:hall)] - [cir ~] + =* messages messages.str + =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] + =/ peers=(map circle:hall (set @p)) + %- ~(rep by rem.pes.piz) + |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] + ^+ acc + (~(put by acc) cir (silt (turn ~(tap by grp) head))) + :: + =. str + %= str + messages (~(put by messages) circle nes.piz) + peers + %- ~(uni by peers.str) + (~(put by peers) circle ~(key by loc.pes.piz)) + == + :_ this(str str) + (send-chat-update [[%messages circle 0 (lent messages) nes.piz] str]) :: - =/ localpeers=(set @p) (silt (turn ~(tap by loc.pes.piz) head)) + :: fill inbox config and remote configs with prize data + :: + =/ circles=(list circle:hall) (turn ~(tap in src.loc.cos.piz) head) :: =/ peers=(map circle:hall (set @p)) %- ~(rep by rem.pes.piz) |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] - ^- (map circle:hall (set @p)) + ^+ acc (~(put by acc) cir (silt (turn ~(tap by grp) head))) :: :- %+ turn ~(tap in (~(del in (silt circles)) [our.bol %inbox])) |= cir=circle:hall - ^- move - =/ wir/wire /circle/[(scot %p our.bol)]/[nom.cir]/config/group - =/ pat/path /circle/[nom.cir]/config/group - [ost.bol %peer wir [our.bol %hall] pat] + %+ hall-peer + /circle/(scot %p our.bol)/[nom.cir]/config/group + /circle/[nom.cir]/config/group %= this inbox.str loc.cos.piz - configs.str configs - messages.str (molt meslis) - peers.str (~(put by peers) [our.bol %inbox] localpeers) - == - :: - :: fill remote configs with message data - :: - =* messages messages.str - =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] - =/ localpeers=(set @p) (silt (turn ~(tap by loc.pes.piz) head)) + peers.str (~(put by peers) [our.bol %inbox] ~(key by loc.pes.piz)) :: - =/ peers=(map circle:hall (set @p)) - %- ~(rep by rem.pes.piz) - |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] - ^- (map circle:hall (set @p)) - (~(put by acc) cir (silt (turn ~(tap by grp) head))) - =/ sta - %= str - messages (~(put by messages) circle nes.piz) - peers (~(uni by peers.str) (~(put by peers) circle localpeers)) - == - =/ messageupdate=update [%messages circle 0 (lent messages) nes.piz] - :_ this(str sta) - (send-chat-update [messageupdate sta]) + configs.str + %- ~(uni in configs.str) + ^- (map circle:hall (unit config:hall)) + (~(run by rem.cos.piz) some) + :: + messages.str + %- molt + %+ turn circles + |= cir=circle:hall + ^- [circle:hall (list envelope:hall)] + [cir ~] + == == :: :: +diff-hall-rumor: handle updates to hall state @@ -252,15 +216,25 @@ ?+ i.wir (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: - :: %circles + %circles + (handle-rumor-circles rum) :: - %circles + %circle + (handle-rumor-circle wir rum) + :: + == +:: +:: +handle-rumor-circles +:: +++ handle-rumor-circles + |= rum=rumor:hall + ^- (quip move _this) ?> ?=(%circles -.rum) =/ cis ?: add.rum (~(put in circles.str) cir.rum) (~(del in circles.str) cir.rum) - =/ sta + =. str %= str circles cis peers @@ -268,37 +242,81 @@ (~(put by peers.str) [our.bol cir.rum] ~) (~(del by peers.str) [our.bol cir.rum]) == - :_ this(str sta) - (send-chat-update [[%circles cis] sta]) - :: - :: - :: %circle: fill remote configs with message data - :: - %circle + :_ this(str str) + (send-chat-update [[%circles cis] str]) +:: +++ handle-rumor-circle + |= [wir=wire rum=rumor:hall] + ^- (quip move _this) ?> ?=(%circle -.rum) - =* sto rum.rum - ?+ -.sto + ?+ -.rum.rum [~ this] :: - :: %gram: + :: %gram: new message :: - %gram + %gram + (handle-rumor-circle-gram wir rum.rum) + :: + :: status: status update + :: + %status + (handle-rumor-circle-status rum.rum) + :: + :: %config: config has changed + :: + %config + ?+ -.dif.rum.rum + [~ this] + :: + :: %full: set all of config without side effects + :: + %full + =* conf cof.dif.rum.rum + =. configs.str (~(put by configs.str) cir.rum.rum `conf) + :_ this(str str) + (send-chat-update [[%config cir.rum.rum conf] str]) + :: + :: %read: the read count of one of our configs has changed + :: + %read + (handle-rumor-circle-config-read rum.rum) + :: + :: %source: the sources of our inbox have changed + :: + %source + (handle-rumor-circle-config-source rum.rum) + :: + :: %remove: remove a circle + :: + %remove + =. str + %= str + configs (~(del by configs.str) cir.rum.rum) + messages (~(del by messages.str) cir.rum.rum) + peers (~(del by peers.str) cir.rum.rum) + == + :_ this(str str) + (send-chat-update [[%delete cir.rum.rum] str]) + :: + == + == +:: +++ handle-rumor-circle-gram + |= [wir=wire sto=rumor-story:hall] + ^- (quip move _this) ?> ?=(%gram -.sto) =* messages messages.str =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] =/ nes=(unit (list envelope:hall)) (~(get by messages) circle) ?~ nes [~ this] - =/ sta - %= str - messages (~(put by messages) circle (snoc u.nes nev.sto)) - == - :_ this(str sta) - (send-chat-update [[%message circle nev.sto] sta]) - :: - :: status: - :: - %status + =. messages.str (~(put by messages) circle (snoc u.nes nev.sto)) + :_ this(str str) + (send-chat-update [[%message circle nev.sto] str]) +:: +++ handle-rumor-circle-status + |= sto=rumor-story:hall + ^- (quip move _this) ?> ?=(%status -.sto) =/ upeers=(unit (set @p)) (~(get by peers.str) cir.sto) ?~ upeers @@ -307,139 +325,86 @@ ?: =(%remove -.dif.sto) (~(del in u.upeers) who.sto) (~(put in u.upeers) who.sto) - =/ sta - %= str - peers (~(put by peers.str) cir.sto peers) - == - :_ this(str sta) - (send-chat-update [[%peers cir.sto peers] sta]) - :: - :: %config: config has changed - :: - %config - =* circ cir.sto - :: - ?+ -.dif.sto + =. peers.str (~(put by peers.str) cir.sto peers) + :_ this(str str) + (send-chat-update [[%peers cir.sto peers] str]) +:: +++ handle-rumor-circle-config-read + |= sto=rumor-story:hall + ^- (quip move _this) + ?> ?=(%config -.sto) + ?> ?=(%read -.dif.sto) + ?: =(cir.sto [our.bol %inbox]) + :: ignore when cir.sto is inbox [~ this] + =/ conf=(unit config:hall) (~(got by configs.str) cir.sto) + ?~ conf + [~ this] + =. red.u.conf red.dif.sto + =. configs.str (~(put by configs.str) cir.sto conf) + :_ this(str str) + (send-chat-update [[%config cir.sto u.conf] str]) +:: +:: +handle-rumor-circle-config-source: on source, subscribe and add to inbox +:: on remove source, send delete and remove data from state +:: +++ handle-rumor-circle-config-source + |= sto=rumor-story:hall + ^- (quip move _this) + ?> ?=(%config -.sto) + ?> ?=(%source -.dif.sto) + ?. =(cir.sto [our.bol %inbox]) + :: ignore when cir.sto is not inbox + [~ this] + =* circ cir.src.dif.sto + =/ wir /circle/(scot %p hos.circ)/[nom.circ]/grams/0/config/group + :: we've added a source to our inbox :: - :: %full: set all of config without side effects - :: - %full - =* conf cof.dif.sto - =/ sta - %= str - configs (~(put by configs.str) circ `conf) + ?: add.dif.sto + =. str + %_ str + src.inbox (~(put in src.inbox.str) src.dif.sto) + :: + configs + ?: (~(has by configs.str) circ) + configs.str + (~(put by configs.str) circ ~) == - :_ this(str sta) - (send-chat-update [[%config circ conf] sta]) - :: - :: %read: the read count of one of our configs has changed - :: - %read - ?: =(circ [our.bol %inbox]) - :: ignore when circ is inbox - [~ this] - =/ uconf/(unit config:hall) (~(got by configs.str) circ) - ?~ uconf - [~ this] - =/ conf/config:hall - %= u.uconf - red red.dif.sto - == - =/ sta - %= str - configs (~(put by configs.str) circ `conf) - == - :_ this(str sta) - (send-chat-update [[%config circ conf] sta]) - :: - :: %source: the sources of our inbox have changed - :: - %source - ?. =(circ [our.bol %inbox]) - :: ignore when circ is not inbox - [~ this] - =* affectedcir cir.src.dif.sto - =/ newwir/wire - /circle/(scot %p hos.affectedcir)/[nom.affectedcir]/grams/0/config/group - =/ pat/path /circle/[nom.affectedcir]/grams/0/config/group - :: we've added a source to our inbox :: - ?: add.dif.sto - =/ newinbox %= inbox.str - src (~(put in src.inbox.str) src.dif.sto) - == - =/ sta - %= str - inbox newinbox - :: - configs - ?: (~(has by configs.str) affectedcir) - configs.str - (~(put by configs.str) affectedcir ~) - == - :: - :_ this(str sta) - %+ weld - [ost.bol %peer newwir [hos.affectedcir %hall] pat]~ - (send-chat-update [[%inbox newinbox] sta]) + =/ pax /circle/[nom.circ]/grams/0/config/group + :_ this(str str) + :- [ost.bol %peer wir [hos.circ %hall] pax] + (send-chat-update [[%inbox inbox.str] str]) + :: + =. src.inbox.str (~(del in src.inbox.str) src.dif.sto) + :: we've removed a source from our inbox + :: + =. str + %= str + inbox inbox.str :: - =/ newinbox %= inbox.str - src (~(del in src.inbox.str) src.dif.sto) + configs (~(del by configs.str) circ) + messages (~(del by messages.str) circ) + peers (~(del by peers.str) circ) == - :: we've removed a source from our inbox + =/ fake=circle:hall + [our.bol (crip (weld (trip 'hall-internal-') (trip nom.circ)))] + :: + :_ this(str str) + ;: weld + ^- (list move) + :: just forward the delete to our clients :: - =/ sta - %= str - inbox newinbox - :: - configs (~(del by configs.str) affectedcir) - messages (~(del by messages.str) affectedcir) - peers (~(del by peers.str) affectedcir) - == - =/ fakecir=circle:hall - :- our.bol - (crip (weld (trip 'hall-internal-') (trip nom.affectedcir))) - :: - ?~ (~(get by configs.str) fakecir) - :: just forward the delete to our clients - :: - :_ this(str sta) - :- [ost.bol %pull newwir [hos.affectedcir %hall] ~] - %+ weld - (send-chat-update [[%inbox newinbox] sta]) - (send-chat-update [[%delete affectedcir] sta]) + ?~ (~(get by configs.str) fake) + [ost.bol %pull wir [hos.circ %hall] ~]~ :: if we get a delete from another ship, delete our fake circle copy :: - =/ deletefake [%hall-action [%delete nom.fakecir ~]] - :_ this(str sta) - :- [ost.bol %pull newwir [hos.affectedcir %hall] ~] - :- [ost.bol %poke /fake [our.bol %hall] deletefake] - %+ weld - (send-chat-update [[%inbox newinbox] sta]) - (send-chat-update [[%delete affectedcir] sta]) + :- [ost.bol %pull wir [hos.circ %hall] ~] + [ost.bol %poke /f [our.bol %hall] [%hall-action [%delete nom.fake ~]]]~ :: - :: %remove: remove a circle - :: - %remove - =/ sta - %= str - configs (~(del by configs.str) circ) - messages (~(del by messages.str) circ) - peers (~(del by peers.str) circ) - == - :_ this(str sta) - (send-chat-update [[%delete circ] sta]) - :: + (send-chat-update [[%inbox inbox.str] str]) + (send-chat-update [[%delete circ] str]) == - :: end of branching on dif.sto type - == - :: end of branching on sto type - == - :: end of i.wir branching -:: -:: +lient arms -:: :: :: +bound: lient tells us we successfully bound our server to the ~chat url :: @@ -587,36 +552,36 @@ ++ send-chat-update |= [upd=update str=streams] ^- (list move) - =/ updates=(list move) + =/ jon (construct-tile-json str) + :: + %+ weld + ^- (list move) %+ turn (prey:pubsub:userlib /primary bol) |= [=bone *] [bone %diff %chat-update upd] - :: - =/ jon (construct-tile-json str) - =/ tile-updates=(list move) - %+ turn (prey:pubsub:userlib /chattile bol) - |= [=bone *] - [bone %diff %json jon] - :: - (weld updates tile-updates) + ^- (list move) + %+ turn (prey:pubsub:userlib /chattile bol) + |= [=bone *] + [bone %diff %json jon] :: ++ construct-tile-json |= str=streams ^- json - =/ numbers/(list [circle:hall @ud]) - %+ turn ~(tap by messages.str) + :- %o + %- my + :~ ['config' (config-to-json str)] + :: + :- 'numbers' + %- numbers-to-json + ^- (list [circle:hall @ud]) + %+ turn ~(tap by messages.str) |= [cir=circle:hall lis=(list envelope:hall)] ^- [circle:hall @ud] ?~ lis [cir 0] =/ last (snag (dec (lent lis)) `(list envelope:hall)`lis) [cir (add num.last 1)] - =/ maptjson=(map @t json) - %- my - :~ ['config' (config-to-json str)] - ['numbers' (numbers-to-json numbers)] - == - [%o maptjson] + == :: ++ launch-poke |= [=path =cord] diff --git a/pkg/arvo/lib/chat.hoon b/pkg/arvo/lib/chat.hoon index d0bf9b57f..6bb69d594 100644 --- a/pkg/arvo/lib/chat.hoon +++ b/pkg/arvo/lib/chat.hoon @@ -1,8 +1,6 @@ /- *chat, hall /+ hall-json |% -:: -:: ++ msg-to-json =, enjs:format |= upd=update From dafec48b364b66e2049e36b8786d3466ca289ca3 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Wed, 28 Aug 2019 13:35:36 -0700 Subject: [PATCH 5/5] Added another round of changes --- pkg/arvo/app/chat.hoon | 33 +++++++++++--------- pkg/interface/chat/src/js/components/root.js | 16 +++++----- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/pkg/arvo/app/chat.hoon b/pkg/arvo/app/chat.hoon index 5c07152ac..a1320f561 100644 --- a/pkg/arvo/app/chat.hoon +++ b/pkg/arvo/app/chat.hoon @@ -155,7 +155,7 @@ :: fill remote configs with message data :: =* messages messages.str - =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] + =/ circle [`@p`(slav %p &2:wir) &3:wir] =/ peers=(map circle:hall (set @p)) %- ~(rep by rem.pes.piz) |= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))] @@ -183,7 +183,10 @@ (~(put by acc) cir (silt (turn ~(tap by grp) head))) :: :- - %+ turn ~(tap in (~(del in (silt circles)) [our.bol %inbox])) + %+ turn + %~ tap in + %- ~(del in (silt circles)) + [our.bol %inbox] |= cir=circle:hall %+ hall-peer /circle/(scot %p our.bol)/[nom.cir]/config/group @@ -193,7 +196,7 @@ peers.str (~(put by peers) [our.bol %inbox] ~(key by loc.pes.piz)) :: configs.str - %- ~(uni in configs.str) + %- ~(uni by configs.str) ^- (map circle:hall (unit config:hall)) (~(run by rem.cos.piz) some) :: @@ -306,8 +309,9 @@ ^- (quip move _this) ?> ?=(%gram -.sto) =* messages messages.str - =/ circle=circle:hall [`@p`(slav %p &2:wir) &3:wir] - =/ nes=(unit (list envelope:hall)) (~(get by messages) circle) + =/ circle [`@p`(slav %p &2:wir) &3:wir] + =/ nes=(unit (list envelope:hall)) + (~(get by messages) circle) ?~ nes [~ this] =. messages.str (~(put by messages) circle (snoc u.nes nev.sto)) @@ -454,11 +458,11 @@ :: paginated message data :: [%'~chat' %scroll @t @t @t @t ~] - =/ cir=circle:hall [(slav %p &3:site.request-line) &4:site.request-line] + =/ cir [(slav %p &3:site.request-line) &4:site.request-line] =/ start=@ud (need (rush &5:site.request-line dem)) =/ parsedend=@ud (need (rush &6:site.request-line dem)) =* messages messages.str - =/ envs/(unit (list envelope:hall)) (~(get by messages) cir) + =/ envs=(unit (list envelope:hall)) (~(get by messages) cir) ?~ envs [~ this] ?: (gte start (lent u.envs)) @@ -468,13 +472,14 @@ (dec (lent u.envs)) parsedend =/ offset (sub end start) - =/ jon=json %- msg-to-json - :* %messages - cir - start - end - (swag [start offset] u.envs) - == + =/ jon + %- msg-to-json + :* %messages + cir + start + end + (swag [start offset] u.envs) + == :_ this [ost.bol %http-response (json-response:app (json-to-octs jon))]~ :: diff --git a/pkg/interface/chat/src/js/components/root.js b/pkg/interface/chat/src/js/components/root.js index cbf1fb115..8fc099fe5 100644 --- a/pkg/interface/chat/src/js/components/root.js +++ b/pkg/interface/chat/src/js/components/root.js @@ -36,7 +36,7 @@ export class Root extends Component { let configs = !!state.configs ? state.configs : {}; let circles = Object.keys(configs).filter((conf) => { - return !!configs[conf] && conf.split('/')[1] !== 'i'; + return configs[conf] !== undefined && conf.split('/')[1] !== 'i'; }); let messages = _.get(state, 'messages', {}); @@ -87,7 +87,7 @@ export class Root extends Component { inviteConfig = configs[`~${window.ship}/i`]; } - const renderChannelsSidebar = (props) => ( + const renderChannelSidebar = (props) => ( { return ( + sidebar={renderChannelSidebar(props)}>

Home

@@ -124,7 +124,7 @@ export class Root extends Component { return ( + sidebar={renderChannelSidebar(props)}> { return ( + sidebar={renderChannelSidebar(props)}> + sidebar={renderChannelSidebar(props) }> { return ( + sidebar={renderChannelSidebar(props) }> + sidebar={renderChannelSidebar(props) }>