Info about current irc connections now gets sent to the client, the correct nick shows up when sending messages
This commit is contained in:
parent
83ddce0468
commit
9012e4dee5
@ -1,4 +1,5 @@
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var socket = require('../socket');
|
||||
|
||||
|
@ -4,7 +4,8 @@ var socket = require('../socket');
|
||||
|
||||
var serverActions = Reflux.createActions([
|
||||
'connect',
|
||||
'disconnect'
|
||||
'disconnect',
|
||||
'load'
|
||||
]);
|
||||
|
||||
serverActions.connect.preEmit = function(server, nick, username) {
|
||||
@ -19,4 +20,8 @@ serverActions.disconnect.preEmit = function(server) {
|
||||
socket.send('quit', { server: server });
|
||||
};
|
||||
|
||||
socket.on('servers', function(data) {
|
||||
serverActions.load(data);
|
||||
});
|
||||
|
||||
module.exports = serverActions;
|
@ -2,21 +2,18 @@ var React = require('react');
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var serverStore = require('../stores/server');
|
||||
var channelStore = require('../stores/channel');
|
||||
var selectedTabStore = require('../stores/selectedTab');
|
||||
var tabActions = require('../actions/tab');
|
||||
|
||||
var TabList = React.createClass({
|
||||
mixins: [
|
||||
Reflux.connect(serverStore, 'servers'),
|
||||
Reflux.connect(channelStore, 'channels'),
|
||||
Reflux.connect(selectedTabStore, 'selectedTab')
|
||||
],
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
servers: serverStore.getState(),
|
||||
channels: channelStore.getState(),
|
||||
selectedTab: selectedTabStore.getState()
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ var messageStore = Reflux.createStore({
|
||||
send: function(message, to, server) {
|
||||
addMessage({
|
||||
server: server,
|
||||
from: 'self',
|
||||
from: serverStore.getNick(server),
|
||||
to: to,
|
||||
message: message
|
||||
}, to);
|
||||
|
@ -1,4 +1,5 @@
|
||||
var Reflux = require('reflux');
|
||||
var _ = require('lodash');
|
||||
|
||||
var actions = require('../actions/server');
|
||||
|
||||
@ -11,13 +12,24 @@ var serverStore = Reflux.createStore({
|
||||
|
||||
connect: function(server, nick, username) {
|
||||
servers[server] = {
|
||||
server: server,
|
||||
address: server,
|
||||
nick: nick,
|
||||
username: username
|
||||
};
|
||||
this.trigger(servers);
|
||||
},
|
||||
|
||||
load: function(storedServers) {
|
||||
_.each(storedServers, function(server) {
|
||||
servers[server.address] = server;
|
||||
});
|
||||
this.trigger(servers);
|
||||
},
|
||||
|
||||
getNick: function(server) {
|
||||
return servers[server].nick;
|
||||
},
|
||||
|
||||
getState: function() {
|
||||
return servers;
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Address string
|
||||
Nick string
|
||||
Username string
|
||||
Realname string
|
||||
Address string `json:"address"`
|
||||
Nick string `json:"nick"`
|
||||
Username string `json:"username"`
|
||||
Realname string `json:"realname"`
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
|
@ -52,6 +52,7 @@ func handleWS(ws *websocket.Conn) {
|
||||
}
|
||||
|
||||
session.sendJSON("channels", channels)
|
||||
session.sendJSON("servers", session.user.GetServers())
|
||||
} else {
|
||||
session = NewSession()
|
||||
session.user = storage.NewUser(UUID)
|
||||
|
Loading…
Reference in New Issue
Block a user