diff --git a/client/src/js/actions/tab.js b/client/src/js/actions/tab.js
index 10be863d..3a249794 100644
--- a/client/src/js/actions/tab.js
+++ b/client/src/js/actions/tab.js
@@ -6,6 +6,12 @@ var tabActions = Reflux.createActions([
'select'
]);
-tabActions.select.preEmit = () => routeActions.navigate('app');
+tabActions.select.preEmit = (server, channel) => {
+ if (channel) {
+ routeActions.navigate('/' + server + '/' + channel.slice(1))
+ } else {
+ routeActions.navigate('/' + server);
+ }
+};
module.exports = tabActions;
\ No newline at end of file
diff --git a/client/src/js/app.js b/client/src/js/app.js
index 4b6906c4..4c8d1172 100644
--- a/client/src/js/app.js
+++ b/client/src/js/app.js
@@ -26,7 +26,9 @@ var routes = (
-
+
+
+
);
diff --git a/client/src/js/command.js b/client/src/js/command.js
index ab53890a..f5617542 100644
--- a/client/src/js/command.js
+++ b/client/src/js/command.js
@@ -45,7 +45,11 @@ messageActions.command.listen(function(line, channel, server) {
case 'topic':
var topic = channelStore.getTopic(server, channel);
if (topic) {
- messageActions.inform(topic, server, channel);
+ messageActions.add({
+ server: server,
+ to: channel,
+ message: topic
+ });
} else {
messageActions.inform('No topic set', server, channel);
}
diff --git a/client/src/js/components/Chat.jsx b/client/src/js/components/Chat.jsx
index ccec3540..8a453dae 100644
--- a/client/src/js/components/Chat.jsx
+++ b/client/src/js/components/Chat.jsx
@@ -1,11 +1,26 @@
var React = require('react');
+var Reflux = require('reflux');
+var Router = require('react-router');
var ChatTitle = require('./ChatTitle.jsx');
var MessageBox = require('./MessageBox.jsx');
var MessageInput = require('./MessageInput.jsx');
var UserList = require('./UserList.jsx');
+var tabActions = require('../actions/tab');
var Chat = React.createClass({
+ mixins: [Router.State],
+
+ componentWillMount: function() {
+ var p = this.getParams();
+
+ if (p.channel) {
+ tabActions.select(p.server, '#' + p.channel);
+ } else if (p.server) {
+ tabActions.select(p.server);
+ }
+ },
+
render: function() {
return (
diff --git a/client/src/js/irc.js b/client/src/js/irc.js
index 09d6fdb5..50e68c46 100644
--- a/client/src/js/irc.js
+++ b/client/src/js/irc.js
@@ -5,6 +5,7 @@ var selectedTabStore = require('./stores/selectedTab');
var channelActions = require('./actions/channel');
var messageActions = require('./actions/message');
var serverActions = require('./actions/server');
+var routeActions = require('./actions/route');
socket.on('join', function(data) {
channelActions.addUser(data.user, data.server, data.channels[0]);
@@ -70,6 +71,9 @@ socket.on('whois', function(data) {
});
socket.on('servers', function(data) {
+ if (data === null) {
+ routeActions.navigate('connect');
+ }
serverActions.load(data);
});
diff --git a/client/src/js/stores/selectedTab.js b/client/src/js/stores/selectedTab.js
index 7f71e5ec..7fda564c 100644
--- a/client/src/js/stores/selectedTab.js
+++ b/client/src/js/stores/selectedTab.js
@@ -7,11 +7,6 @@ var channelActions = require('../actions/channel');
var serverActions = require('../actions/server');
var selectedTab = {};
-var stored = localStorage.selectedTab;
-
-if (stored) {
- selectedTab = JSON.parse(stored);
-}
var selectedTabStore = Reflux.createStore({
init: function() {
@@ -19,7 +14,7 @@ var selectedTabStore = Reflux.createStore({
this.listenTo(channelActions.part, 'part');
this.listenTo(serverActions.disconnect, 'disconnect');
this.listenTo(channelActions.addUser, 'userAdded');
- this.listenTo(channelActions.load, 'loadChannels');
+ //this.listenTo(channelActions.load, 'loadChannels');
this.listenTo(serverActions.load, 'loadServers');
},
@@ -65,17 +60,18 @@ var selectedTabStore = Reflux.createStore({
},
loadChannels: function(channels) {
- if (selectedTab.channel && !_.find(channels, { name: selectedTab.channel })) {
- selectedTab.channel = null;
- selectedTab.name = null;
- this.trigger(selectedTab);
- }
+
},
loadServers: function(servers) {
- if (selectedTab.server && !_.find(servers, { address: selectedTab.server })) {
+ var server = _.find(servers, { address: selectedTab.server });
+
+ if (!server) {
selectedTab = {};
this.trigger(selectedTab);
+ } else if (!selectedTab.channel) {
+ selectedTab.name = server.name;
+ this.trigger(selectedTab);
}
},
diff --git a/irc.go b/irc.go
index 24637ff5..1f179e95 100644
--- a/irc.go
+++ b/irc.go
@@ -4,6 +4,7 @@ import (
"bufio"
"crypto/tls"
"fmt"
+ "log"
"net"
"strings"
"sync"
@@ -236,6 +237,7 @@ func (i *IRC) recv() {
for {
line, err := i.reader.ReadString('\n')
if err != nil {
+ log.Println("IRC connection to", i.Server, "died")
return
}