diff --git a/apps/chat/src/js/components/chat.js b/apps/chat/src/js/components/chat.js index 00e71f5fa7..e0e45c5ab0 100644 --- a/apps/chat/src/js/components/chat.js +++ b/apps/chat/src/js/components/chat.js @@ -36,6 +36,7 @@ export class ChatScreen extends Component { componentDidMount() { this.updateNumPeople(); + this.updateReadNumber(); } componentWillUnMount() { diff --git a/apps/chat/src/js/components/new.js b/apps/chat/src/js/components/new.js index 77b2b30730..083718e0bc 100644 --- a/apps/chat/src/js/components/new.js +++ b/apps/chat/src/js/components/new.js @@ -18,6 +18,17 @@ export class NewScreen extends Component { this.invChange = this.invChange.bind(this); } + componentDidUpdate(prevProps, prevState) { + const { props, state } = this; + + if (prevProps.circles !== props.circles) { + let station = `~${window.ship}/${state.idName}`; + if (props.circles.includes(station)) { + props.history.push('/~chat/' + station); + } + } + } + idChange(event) { this.setState({ idName: event.target.value, @@ -33,7 +44,7 @@ export class NewScreen extends Component { const { props, state } = this; if (!state.idName || !!state.showNameError) { return; } - let station = `~${props.api.authTokens.ship}/${state.idName}`; + let station = `~${window.ship}/${state.idName}`; let actions = [ { create: { @@ -79,7 +90,6 @@ export class NewScreen extends Component { } props.api.chat(actions); - props.history.push('/~chat/' + station); } render() { diff --git a/apps/chat/src/js/components/root.js b/apps/chat/src/js/components/root.js index b2035235bb..4e1b0dd49b 100644 --- a/apps/chat/src/js/components/root.js +++ b/apps/chat/src/js/components/root.js @@ -139,6 +139,7 @@ export class Root extends Component { }> diff --git a/apps/chat/src/js/components/sidebar.js b/apps/chat/src/js/components/sidebar.js index 0fff33f19b..032e9167c6 100644 --- a/apps/chat/src/js/components/sidebar.js +++ b/apps/chat/src/js/components/sidebar.js @@ -13,12 +13,47 @@ export class Sidebar extends Component { constructor(props) { super(props); + this.state = { + invites: [] + }; + this.setInvitesToReadInterval = setInterval( this.setInvitesToRead.bind(this), 1000 ); } + componentDidMount() { + this.filterInvites(); + } + + componentDidUpdate(prevProps, prevState) { + if (prevProps !== this.props) { + this.filterInvites(); + } + } + + filterInvites() { + const { props } = this; + let invites = []; + + let filterInvites = {}; + props.invites.forEach((msg) => { + let uid = _.get(msg, 'gam.sep.ire.top', false); + if (!uid) { + invites.push(msg.gam); + } else { + filterInvites[uid] = true; + } + }); + + invites = invites.filter((msg) => { + return !(msg.uid in filterInvites); + }) + + this.setState({ invites }); + } + componentWillUnmount() { if (this.setInvitesToReadInterval) { clearInterval(this.setInvitesToReadInterval); @@ -27,14 +62,21 @@ export class Sidebar extends Component { } setInvitesToRead() { - const { props } = this; + const { props, state } = this; + if ( props.inviteConfig && 'red' in props.inviteConfig && - props.invites.length > 0 && - props.inviteConfig.red < (props.invites[props.invites.length - 1].num + 1) + props.invites.length > 0 ) { - props.api.read('i', props.invites[props.invites.length - 1].num + 1); + let invNum = (props.invites[props.invites.length - 1].num + 1); + + if ( + props.inviteConfig.red < invNum && + (invNum - props.inviteConfig.red) > state.invites.length + ) { + props.api.read('i', invNum - state.invites.length); + } } } @@ -43,7 +85,7 @@ export class Sidebar extends Component { } render() { - const { props } = this; + const { props, state } = this; let station = props.match.params.ship + '/' + props.match.params.station; let sidebarItems = props.circles @@ -93,21 +135,7 @@ export class Sidebar extends Component { ); }); - let invites = []; - - let filterInvites = {}; - props.invites.forEach((msg) => { - let uid = _.get(msg, 'gam.sep.ire.top', false); - if (!uid) { - invites.push(msg.gam); - } else { - filterInvites[uid] = true; - } - }); - - let inviteItems = invites.filter((msg) => { - return !(msg.uid in filterInvites); - }).map((inv) => { + let inviteItems = state.invites.map((inv) => { return ( ?=(%gram -.sto) =* messages messages.str.sta =/ circle/circle:hall [`@p`(slav %p &2:wir) &3:wir] - =/ nes/(list envelope:hall) (~(got by messages) circle) - =/ str %= str.sta - messages (~(put by messages) circle (snoc nes nev.sto)) - == + =/ 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) :: @@ -574,15 +571,15 @@ (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: %circle - =/ shp/@p (slav %p &2:wir) - =/ pat /circle/[&3:wir]/config/group - ?: =(&3:wir 'inbox') - :_ this - [ost.bol %peer wir [shp %hall] pat]~ - ?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~]) - :_ this - [ost.bol %peer wir [shp %hall] pat]~ - [~ this] + =/ shp/@p (slav %p &2:wir) + =/ pat /circle/[&3:wir]/config/group + ?: =(&3:wir 'inbox') + :_ this + [ost.bol %peer wir [shp %hall] pat]~ + ?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~]) + :_ this + [ost.bol %peer wir [shp %hall] pat]~ + [~ this] :: %circles :_ this @@ -600,15 +597,15 @@ (mean [leaf+"invalid wire for diff: {(spud wir)}"]~) :: %circle - =/ shp/@p (slav %p &2:wir) - =/ pat /circle/[&3:wir]/config/group - ?: =(&3:wir 'inbox') - :_ this - [ost.bol %peer wir [shp %hall] pat]~ - ?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~]) - :_ this - [ost.bol %peer wir [shp %hall] pat]~ - [~ this] + =/ shp/@p (slav %p &2:wir) + =/ pat /circle/[&3:wir]/config/group + ?: =(&3:wir 'inbox') + :_ this + [ost.bol %peer wir [shp %hall] pat]~ + ?: (~(has in src.inbox.str.sta) [[shp &3:wir] ~]) + :_ this + [ost.bol %peer wir [shp %hall] pat]~ + [~ this] :: %circles :_ this diff --git a/apps/chat/urbit/app/chat/js/index.js b/apps/chat/urbit/app/chat/js/index.js index e2fc2a4a56..2c78a38ddb 100644 --- a/apps/chat/urbit/app/chat/js/index.js +++ b/apps/chat/urbit/app/chat/js/index.js @@ -17,10 +17,6 @@ return module = { exports: {} }, fn(module, module.exports), module.exports; } - function getCjsExportFromNamespace (n) { - return n && n.default || n; - } - /* object-assign (c) Sindre Sorhus @@ -45901,8 +45897,6 @@ handleEvent(data) { let json = data.data; - console.log(json); - this.initialReducer.reduce(json, this.state); this.configReducer.reduce(json, this.state); this.updateReducer.reduce(json, this.state); @@ -47902,8 +47896,6 @@ isBuffer: isBuffer }); - var require$$0 = getCjsExportFromNamespace(bufferEs6); - var bn = createCommonjsModule(function (module) { (function (module, exports) { @@ -47956,7 +47948,7 @@ var Buffer; try { - Buffer = require$$0.Buffer; + Buffer = bufferEs6.Buffer; } catch (e) { } @@ -56741,12 +56733,47 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ constructor(props) { super(props); + this.state = { + invites: [] + }; + this.setInvitesToReadInterval = setInterval( this.setInvitesToRead.bind(this), 1000 ); } + componentDidMount() { + this.filterInvites(); + } + + componentDidUpdate(prevProps, prevState) { + if (prevProps !== this.props) { + this.filterInvites(); + } + } + + filterInvites() { + const { props } = this; + let invites = []; + + let filterInvites = {}; + props.invites.forEach((msg) => { + let uid = lodash.get(msg, 'gam.sep.ire.top', false); + if (!uid) { + invites.push(msg.gam); + } else { + filterInvites[uid] = true; + } + }); + + invites = invites.filter((msg) => { + return !(msg.uid in filterInvites); + }); + + this.setState({ invites }); + } + componentWillUnmount() { if (this.setInvitesToReadInterval) { clearInterval(this.setInvitesToReadInterval); @@ -56755,14 +56782,21 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ } setInvitesToRead() { - const { props } = this; + const { props, state } = this; + if ( props.inviteConfig && 'red' in props.inviteConfig && - props.invites.length > 0 && - props.inviteConfig.red < (props.invites[props.invites.length - 1].num + 1) + props.invites.length > 0 ) { - props.api.read('i', props.invites[props.invites.length - 1].num + 1); + let invNum = (props.invites[props.invites.length - 1].num + 1); + + if ( + props.inviteConfig.red < invNum && + (invNum - props.inviteConfig.red) > state.invites.length + ) { + props.api.read('i', invNum - state.invites.length); + } } } @@ -56771,7 +56805,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ } render() { - const { props } = this; + const { props, state } = this; let station = props.match.params.ship + '/' + props.match.params.station; let sidebarItems = props.circles @@ -56816,45 +56850,31 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ ship: obj.aut, selected: obj.selected, unread: unread, - history: props.history, __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 82}} + history: props.history, __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 124}} ) ); }); - let invites = []; - - let filterInvites = {}; - props.invites.forEach((msg) => { - let uid = lodash.get(msg, 'gam.sep.ire.top', false); - if (!uid) { - invites.push(msg.gam); - } else { - filterInvites[uid] = true; - } - }); - - let inviteItems = invites.filter((msg) => { - return !(msg.uid in filterInvites); - }).map((inv) => { + let inviteItems = state.invites.map((inv) => { return ( react.createElement(SidebarInvite, { key: inv.uid, msg: inv, api: props.api, - config: props.inviteConfig, __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 112}} + config: props.inviteConfig, __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 140}} ) ); }); return ( - react.createElement('div', { className: "h-100 w-100 overflow-x-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 122}} - , react.createElement('div', { className: "pl3 pr3 pt3 pb3 cf" , __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 123}} - , react.createElement('p', { className: "dib w-50 fw-bold body-large" , __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 124}}, "Chat") + react.createElement('div', { className: "h-100 w-100 overflow-x-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 150}} + , react.createElement('div', { className: "pl3 pr3 pt3 pb3 cf" , __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 151}} + , react.createElement('p', { className: "dib w-50 fw-bold body-large" , __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 152}}, "Chat") , react.createElement('a', { className: "dib tr w-50 pointer plus-font" , - onClick: this.onClickNew.bind(this), __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 125}}, "+") + onClick: this.onClickNew.bind(this), __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 153}}, "+") ) - , react.createElement('div', { style: { flexGrow: 1 }, __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 129}} + , react.createElement('div', { style: { flexGrow: 1 }, __self: this, __source: {fileName: _jsxFileName$5, lineNumber: 157}} , inviteItems , sidebarItems ) @@ -57272,6 +57292,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ componentDidMount() { this.updateNumPeople(); + this.updateReadNumber(); } componentWillUnMount() { @@ -57393,7 +57414,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ return ( react.createElement('a', { className: "vanilla hoverline text-600 text-mono" , - href: prettyShip(msg.gam.aut)[1], __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 158}} + href: prettyShip(msg.gam.aut)[1], __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 159}} , prettyShip(`~${msg.gam.aut}`)[0] ) ); @@ -57403,7 +57424,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ react.createElement(Message, { key: msg.gam.uid + Math.random(), msg: msg.gam, - details: details, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 167}} ) + details: details, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 168}} ) ); } @@ -57425,18 +57446,18 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ return ( react.createElement('div', { key: state.station, - className: "h-100 w-100 overflow-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 191}} - , react.createElement('div', { className: "pl2 pt2 bb" , __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 193}} - , react.createElement('h2', {__self: this, __source: {fileName: _jsxFileName$c, lineNumber: 194}}, state.circle) + className: "h-100 w-100 overflow-hidden flex flex-column" , __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 192}} + , react.createElement('div', { className: "pl2 pt2 bb" , __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 194}} + , react.createElement('h2', {__self: this, __source: {fileName: _jsxFileName$c, lineNumber: 195}}, state.circle) , react.createElement(ChatTabBar, { ...props, station: state.station, - numPeers: peers.length, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 195}} ) + numPeers: peers.length, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 196}} ) ) , react.createElement('div', { className: "overflow-y-scroll pt3 flex flex-column-reverse" , style: { height: 'calc(100% - 157px)' }, - onScroll: this.onScroll, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 199}} - , react.createElement('div', { ref: el => { this.scrollElement = el; }, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 203}}) + onScroll: this.onScroll, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 200}} + , react.createElement('div', { ref: el => { this.scrollElement = el; }, __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 204}}) , chatMessages ) , react.createElement(ChatInput, { @@ -57444,7 +57465,7 @@ lyrtesmudnytbyrsenwegfyrmurtelreptegpecnelnevfes\ numMsgs: lastMsgNum, station: state.station, circle: state.circle, - placeholder: "Message...", __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 206}} ) + placeholder: "Message...", __self: this, __source: {fileName: _jsxFileName$c, lineNumber: 207}} ) ) ) } diff --git a/apps/chat/urbit/app/chat/js/tile.js b/apps/chat/urbit/app/chat/js/tile.js index 3346e7a772..1a67ca45d6 100644 --- a/apps/chat/urbit/app/chat/js/tile.js +++ b/apps/chat/urbit/app/chat/js/tile.js @@ -19323,7 +19323,6 @@ render() { const { state } = this; - let inviteNum = 0; let msgNum = 0; let inviteCircle = `~${window.ship}/i`; @@ -19342,37 +19341,34 @@ let host = key.split('/')[0]; if (!state.configs[key]) { break; } + if (!(key in numbers)) { break; } let red = state.configs[key].red; - console.log(key, red, numbers[key]); if (key === inviteCircle) { inviteNum = inviteNum - red + numbers[key]; - console.log('case 1', inviteNum); } else if (host === `~${window.ship}`) { msgNum = msgNum - red + numbers[key]; - console.log('case 2', msgNum); } else { msgNum = msgNum + numbers[key]; - console.log('case 3', msgNum); } } } return ( - react.createElement('div', { className: "w-100 h-100 relative" , style: { background: '#1a1a1a' }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 72}} - , react.createElement('a', { className: "w-100 h-100 db pa2 no-underline" , href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 73}} + react.createElement('div', { className: "w-100 h-100 relative" , style: { background: '#1a1a1a' }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 68}} + , react.createElement('a', { className: "w-100 h-100 db pa2 no-underline" , href: "/~chat", __self: this, __source: {fileName: _jsxFileName, lineNumber: 69}} , react.createElement('p', { className: "gray", style: { fontWeight: 'bold', fontSize: 14, lineHeight: '24px' - }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 74}}, "Chat") + }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 70}}, "Chat") , react.createElement('img', { className: "absolute", style: { left: 68, top: 65 }, src: "/~chat/img/Tile.png", width: 106, - height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 79}} ) + height: 98, __self: this, __source: {fileName: _jsxFileName, lineNumber: 75}} ) , react.createElement('p', { className: "absolute white" , style: { @@ -19380,7 +19376,7 @@ fontWeight: 600, fontSize: 16, lineHeight: '20px' - }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 85}}, inviteNum, " invites" ) + }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 81}}, inviteNum, " invites" ) , react.createElement('p', { className: "absolute white" , style: { @@ -19388,7 +19384,7 @@ fontWeight: 600, fontSize: 16, lineHeight: '20px' - }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 93}}, msgNum, " new messages" ) + }, __self: this, __source: {fileName: _jsxFileName, lineNumber: 89}}, msgNum, " new messages" ) ) ) ); diff --git a/apps/clock/urbit/app/clock.hoon b/apps/clock/urbit/app/clock.hoon index df1dbf4154..97e726d24c 100644 --- a/apps/clock/urbit/app/clock.hoon +++ b/apps/clock/urbit/app/clock.hoon @@ -39,11 +39,12 @@ ++ prep |= old=(unit ~) ^- (quip move _this) - =/ lismov/(list move) %+ weld - `(list move)`[ost.bol %connect / [~ /'~clock'] %clock]~ - `(list move)`[ost.bol %poke /clock [our.bol %launch] [%noun [%clock /tile '/~clock/js/tile.js']]]~ - :- lismov - this + =/ launchnoun [%noun [%clock /tile '/~clock/js/tile.js']] + :_ this + :~ + [ost.bol %connect / [~ /'~clock'] %clock] + [ost.bol %poke /clock [our.bol %launch] launchnoun] + == :: ++ peer-tile |= pax=path @@ -61,10 +62,10 @@ %- (require-authorization:app ost.bol move this) |= =inbound-request:http-server ^- (quip move _this) - =+ request-line=(parse-request-line url.request.inbound-request) - =+ back-path=(flop site.request-line) + =/ request-line (parse-request-line url.request.inbound-request) + =/ back-path (flop site.request-line) =/ name=@t - =+ back-path=(flop site.request-line) + =/ back-path (flop site.request-line) ?~ back-path '' i.back-path diff --git a/apps/launch/urbit/app/launch.hoon b/apps/launch/urbit/app/launch.hoon index fb04683f99..442bc5e30b 100644 --- a/apps/launch/urbit/app/launch.hoon +++ b/apps/launch/urbit/app/launch.hoon @@ -79,10 +79,12 @@ =/ data/(unit [json url=@t]) (~(get by data.sta) name) ?~ data [~ this] + :: :- %+ turn (prey:pubsub:userlib /main bol) - |= [=bone *] - [bone %diff %json (frond:enjs:format name jon)] + |= [=bone *] + [bone %diff %json (frond:enjs:format name jon)] + :: %= this data.sta (~(put by data.sta) name [jon url.u.data]) == @@ -102,9 +104,9 @@ |= data=tile-data ^- marl %+ turn ~(tap by data) - |= [key=@tas [jon=json url=@t]] - ^- manx - ;script@"{(trip url)}"; + |= [key=@tas [jon=json url=@t]] + ^- manx + ;script@"{(trip url)}"; :: ++ poke-handle-http-request %- (require-authorization:app ost.bol move this) diff --git a/apps/timer/urbit/app/timer.hoon b/apps/timer/urbit/app/timer.hoon index 55f2eee4e4..9c792a4f64 100644 --- a/apps/timer/urbit/app/timer.hoon +++ b/apps/timer/urbit/app/timer.hoon @@ -44,10 +44,12 @@ ++ prep |= old=(unit tim=@da) ^- (quip move _this) - =/ lismov/(list move) %+ weld - `(list move)`[ost.bol %connect / [~ /'~timer'] %timer]~ - `(list move)`[ost.bol %poke /timer [our.bol %launch] [%noun [%timer /tile '/~timer/js/tile.js']]]~ - :- lismov + =/ launchnoun [%noun [%timer /tile '/~timer/js/tile.js']] + :- + :~ + [ost.bol %connect / [~ /'~timer'] %timer] + [ost.bol %poke /timer [our.bol %launch] launchnoun] + == ?~ old this %= this @@ -76,25 +78,21 @@ =/ str/@t +.jon ?: =(str 'start') =/ data/@da (add now.bol ~s10) - :- %+ weld - `(list move)`(send-tile-diff [%s (scot %da data)]) - `(list move)`[ost.bol %wait /timer data]~ - this(tim data) + :_ this(tim data) + [[ost.bol %wait /timer data] (send-tile-diff [%s (scot %da data)])] ?: =(str 'stop') - :- %+ weld - `(list move)`(send-tile-diff [%s '']) - `(list move)`[ost.bol %rest /timer tim]~ - this(tim *@da) + :_ this(tim *@da) + [[ost.bol %rest /timer tim] (send-tile-diff [%s ''])] [~ this] :: ++ poke-handle-http-request %- (require-authorization:app ost.bol move this) |= =inbound-request:http-server ^- (quip move _this) - =+ request-line=(parse-request-line url.request.inbound-request) - =+ back-path=(flop site.request-line) + =/ request-line (parse-request-line url.request.inbound-request) + =/ back-path (flop site.request-line) =/ name=@t - =+ back-path=(flop site.request-line) + =/ back-path (flop site.request-line) ?~ back-path '' i.back-path