diff --git a/main/pub/chat/src/main.css b/main/pub/chat/src/main.css index 93071ebb4..db1df4efa 100644 --- a/main/pub/chat/src/main.css +++ b/main/pub/chat/src/main.css @@ -67,6 +67,9 @@ body { padding: 0; margin: 0; } +.hidden { + display: none; +} #c { width: 66rem; top: 0; diff --git a/main/pub/chat/src/main.js b/main/pub/chat/src/main.js index 0b54f7a56..d626a8fff 100644 --- a/main/pub/chat/src/main.js +++ b/main/pub/chat/src/main.js @@ -85,12 +85,21 @@ module.exports = { return persistence.addSource("main", parts[0], stations); } }, + ping: function(_ping) { + return window.chat.StationPersistence.ping(_ping); + }, loadStations: function(stations) { return StationDispatcher.handleServerAction({ type: "stations-load", stations: stations }); }, + loadMembers: function(members) { + return StationDispatcher.handleServerAction({ + type: "members-load", + members: members + }); + }, createStation: function(station) { StationDispatcher.handleViewAction({ type: "station-create", @@ -197,7 +206,8 @@ module.exports = recl({ messages: MessageStore.getAll(), last: MessageStore.getLast(), fetching: MessageStore.getFetching(), - station: StationStore.getStation() + station: StationStore.getStation(), + stations: StationStore.getStations() }; }, getInitialState: function() { @@ -270,7 +280,71 @@ module.exports = recl({ -},{"../actions/MessageActions.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/actions/MessageActions.coffee","../stores/MessageStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/MessageStore.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MemberComponent.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","moment-timezone":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/moment-timezone/index.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/StationsComponent.coffee":[function(require,module,exports){ +},{"../actions/MessageActions.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/actions/MessageActions.coffee","../stores/MessageStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/MessageStore.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MemberComponent.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","moment-timezone":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/moment-timezone/index.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/StationComponent.coffee":[function(require,module,exports){ +var Member, React, StationActions, StationStore, div, input, recl, textarea, _, _ref; + +_ = require('lodash'); + +React = require('react'); + +recl = React.createClass; + +_ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = _ref[0], input = _ref[1], textarea = _ref[2]; + +StationStore = require('../stores/StationStore.coffee'); + +StationActions = require('../actions/StationActions.coffee'); + +Member = require('./MemberComponent.coffee'); + +module.exports = recl({ + stateFromStore: function() { + return { + members: StationStore.getMembers(), + station: StationStore.getStation() + }; + }, + getInitialState: function() { + return this.stateFromStore(); + }, + componentDidMount: function() { + StationStore.addChangeListener(this._onChangeStore); + return setInterval(this.ping, 10000); + }, + componentWillUnmount: function() { + return StationStore.removeChangeListener(this._onChangeStore); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + ping: function() { + var k, v, _ping, _ref1; + _ping = {}; + _ref1 = this.state.members; + for (k in _ref1) { + v = _ref1[k]; + _ping[k] = "hear"; + } + return StationActions.ping(_ping); + }, + render: function() { + var members; + if (this.state.station && this.state.members[this.state.station]) { + members = _.map(this.state.members[this.state.station], function(state, member) { + return div({}, member + "-" + state.presence); + }); + } else { + members = ""; + } + return div({ + id: "station" + }, members); + } +}); + + + +},{"../actions/StationActions.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/actions/StationActions.coffee","../stores/StationStore.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/stores/StationStore.coffee","./MemberComponent.coffee":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/MemberComponent.coffee","lodash":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/lodash/dist/lodash.js","react":"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/node_modules/react/react.js"}],"/Users/galen/Documents/Projects/urbit.tlon/chat/pub/chat/src/components/StationsComponent.coffee":[function(require,module,exports){ var React, StationActions, StationStore, div, input, recl, _, _ref; _ = require('lodash'); @@ -462,13 +536,17 @@ module.exports = recl({ return this.setState(this.stateFromStore()); }, render: function() { - var iden, name, ship, user; + var iden, k, name, ship, user, _ref1; user = "~" + window.urb.user; iden = StationStore.getMember(user); ship = iden ? iden.ship : user; name = iden ? iden.name : ""; + k = "writing"; + if (!((_ref1 = this.state) != null ? _ref1.station : void 0)) { + k += " hidden"; + } return div({ - className: "writing" + className: k }, [ div({ className: "attr" @@ -526,7 +604,7 @@ rend = React.renderComponent; StationStore = require('./stores/StationStore.coffee'); $(function() { - var $c, MessagesComponent, StationsComponent, WritingComponent; + var $c, MessagesComponent, StationComponent, StationsComponent, WritingComponent; window.chat = {}; window.chat.MessagePersistence = require('./persistence/MessagePersistence.coffee'); window.chat.StationPersistence = require('./persistence/StationPersistence.coffee'); @@ -595,11 +673,11 @@ $(function() { } }; $(window).on('scroll', window.util.checkScroll); - setInterval(window.chat.StationPersistence.ping, 5000); - window.chat.StationPersistence.members(); window.chat.MessagePersistence.listen(window.urb.util.toDate(new Date())); window.chat.StationPersistence.config(); window.chat.StationPersistence.rooms(); + window.chat.StationPersistence.members(); + StationComponent = require('./components/StationComponent.coffee'); StationsComponent = require('./components/StationsComponent.coffee'); MessagesComponent = require('./components/MessagesComponent.coffee'); WritingComponent = require('./components/WritingComponent.coffee'); @@ -607,7 +685,9 @@ $(function() { $c.append("
"); $c.append(""); $c.append(""); + $c.append(""); $c.append("