Added new version of chat

This commit is contained in:
Logan Allen 2019-06-11 11:21:59 -07:00 committed by Isaac Visintainer
parent 64069af56a
commit 4be231b380
6 changed files with 6381 additions and 6321 deletions

View File

@ -81,51 +81,37 @@
++ peer-primary
|= wir=wire
^- (quip move _this)
=/ indices (generate-circle-indices wir)
?~ indices
:_ this
[ost.bol %diff %chat-initial str.sta]~
=* messages messages.str.sta
=/ lisunitmov/(list (unit move))
%+ turn indices
|= [cir=circle:hall start=@ud]
^- (unit move)
=/ wholelist/(unit (list envelope:hall)) (~(get by messages) cir)
?~ wholelist
~
=/ end/@ (lent u.wholelist)
?: (gte start end)
~
:- ~
:* ost.bol
%diff
%chat-update
[%messages cir start end (swag [start end] u.wholelist)]
==
=/ lismov/(list move)
%+ turn
%+ skim lisunitmov
=/ lisunitmov=(list (unit move))
%+ turn ~(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
%+ weld
[ost.bol %diff %chat-config str.sta]~
%+ turn %+ skim lisunitmov
|= umov=(unit move)
^- ?
?~ umov
%.n
%.y
need
:_ this
%+ weld
[ost.bol %diff %chat-config str.sta]~
lismov
::
++ peer-updates
|= wir=wire
^- (quip move _this)
[~ this]
::
++ poke-noun
|= a=*
^- (quip move _this)
~& sta
[~ this]
::
:: +poke-chat: send us an action
::
@ -148,8 +134,9 @@
++ send-chat-update
|= upd=update
^- (list move)
%+ turn (prey:pubsub:userlib /updates bol)
%+ turn (prey:pubsub:userlib /primary bol)
|= [=bone *]
~& bone
[bone %diff %chat-update upd]
::
::
@ -459,6 +446,34 @@
:_ this
[ost.bol %http-response (png-response:app img)]~
::
:: 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))
=* messages messages.str.sta
=/ envs/(unit (list envelope:hall)) (~(get by messages) cir)
?~ envs
[~ this]
?: (gte start (lent u.envs))
[~ this]
=/ end/@
?: (gte parsedend (lent u.envs))
(dec (lent u.envs))
parsedend
=/ offset (sub end start)
=/ jon/json %- msg-to-json
:* %messages
cir
start
end
(swag [start offset] u.envs)
==
:_ this
[ost.bol %http-response (json-response:app (json-to-octs jon))]~
::
::
:: inbox page
::
[%'~chat' *]

File diff suppressed because one or more lines are too long

View File

@ -2206,33 +2206,22 @@
class ChatTile extends react_1 {
constructor(props) {
super(props);
}
renderWrapper(child) {
render() {
return (
react.createElement('div', { className: "bg-dark-gray w-100 h-100" , __self: this, __source: {fileName: _jsxFileName, lineNumber: 14}}
, child
react.createElement('div', { className: "bg-dark-gray w-100 h-100" , __self: this, __source: {fileName: _jsxFileName, lineNumber: 9}}
, react.createElement('a', { className: "w-100 h-100 db" , style: {
paddingTop: 68,
paddingBottom: 68,
paddingLeft: 64,
paddingRight: 64
},
href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 10}}
, react.createElement('img', { src: "/~chat/img/Tile.png", width: 106, height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 17}} )
)
)
);
}
render() {
return this.renderWrapper((
react.createElement('a', { className: "w-100 h-100 db" , style: {
paddingTop: 68,
paddingBottom: 68,
paddingLeft: 64,
paddingRight: 64
},
href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 22}}
, react.createElement('img', { src: "/~chat/img/Tile.png", width: 106, height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 29}} )
)
));
}
}
window.chatTile = ChatTile;

View File

@ -1,4 +1,5 @@
/- hall
/+ hall-json
|%
::
+$ move [bone card]
@ -58,17 +59,36 @@
==
::
+$ action [%actions lis=(list action:hall)]
+$ pareto-mark
$%
[%json pax=path name=@t jon=json]
[%path name=@t obj=(map @t json)]
==
::
::
::
:: +utilities
::
++ msg-to-json
=, enjs:format
|= upd=update
^- json
?> ?=(%messages -.upd)
%+ frond %update
%- pairs
:~
:- %messages
%- pairs
:~
[%circle (circ:enjs:hall-json cir.upd)]
[%start (numb start.upd)]
[%end (numb end.upd)]
[%envelopes [%a (turn env.upd enve:enjs:hall-json)]]
==
==
::
++ parse-chat-command
=, dejs:format
=, dejs:hall-json
%- of
:~
[%messages (ot circle+circ start+ni end+ni ~)]
==
::
+$ indices-internal-state
$:
lis=(list [circle:hall @])

View File

@ -11,7 +11,7 @@
::
++ grab
|%
++ noun streams:chat
++ noun action:chat
++ json
|= jon=^json
=< (parse-chat-action jon)

View File

@ -581,7 +581,6 @@
//
var x = JSON.stringify(
[{"action": "ack", "event-id": parseInt(this.lastEventId)}, j])
console.log(x, this.lastEventId);
req.send(x);
this.lastEventId = this.lastAcknowledgedEventId;
@ -620,22 +619,17 @@
//
var funcs = this.outstandingSubscriptions.get(obj.id);
if (obj.hasOwnProperty("err")) {
console.log(obj);
funcs["err"](obj.err);
this.outstandingSubscriptions.delete(obj.id);
} else {
console.log("Subscription establisthed");
}
} else if (obj.response == "diff") {
console.log("Diff: ", obj);
var funcs = this.outstandingSubscriptions.get(obj.id);
funcs["event"](obj.json);
} else if (obj.response == "quit") {
var funcs = this.outstandingSubscriptions.get(obj.id);
funcs["quit"](obj.err);
this.outstandingSubscriptions.delete(obj.id);
} else {
console.log("Unrecognized response: ", e);
}