Handle double hashtag channel names in URLs
This commit is contained in:
parent
518a530f43
commit
2f1e72876b
@ -8,7 +8,10 @@ var tabActions = Reflux.createActions([
|
||||
|
||||
tabActions.select.preEmit = (server, channel) => {
|
||||
if (channel) {
|
||||
routeActions.navigate('/' + server + '/' + channel.slice(1))
|
||||
while (channel[0] === '#') {
|
||||
channel = channel.slice(1);
|
||||
}
|
||||
routeActions.navigate('/' + server + '/' + channel);
|
||||
} else {
|
||||
routeActions.navigate('/' + server);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ var Chat = React.createClass({
|
||||
mixins: [Router.State],
|
||||
|
||||
componentWillMount: function() {
|
||||
if (!window.loaded) {
|
||||
var p = this.getParams();
|
||||
|
||||
if (p.channel) {
|
||||
@ -19,6 +20,7 @@ var Chat = React.createClass({
|
||||
} else if (p.server) {
|
||||
tabActions.select(p.server);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
@ -6,6 +6,7 @@ var channelActions = require('./actions/channel');
|
||||
var messageActions = require('./actions/message');
|
||||
var serverActions = require('./actions/server');
|
||||
var routeActions = require('./actions/route');
|
||||
var tabActions = require('./actions/tab');
|
||||
|
||||
socket.on('join', function(data) {
|
||||
channelActions.addUser(data.user, data.server, data.channels[0]);
|
||||
@ -71,9 +72,12 @@ socket.on('whois', function(data) {
|
||||
});
|
||||
|
||||
socket.on('servers', function(data) {
|
||||
window.loaded = true;
|
||||
|
||||
if (data === null) {
|
||||
routeActions.navigate('connect');
|
||||
}
|
||||
|
||||
serverActions.load(data);
|
||||
});
|
||||
|
||||
|
@ -5,6 +5,7 @@ var serverStore = require('./server');
|
||||
var actions = require('../actions/tab');
|
||||
var channelActions = require('../actions/channel');
|
||||
var serverActions = require('../actions/server');
|
||||
var routeActions = require('../actions/route');
|
||||
|
||||
var selectedTab = {};
|
||||
|
||||
@ -14,8 +15,9 @@ 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');
|
||||
this.listenTo(routeActions.navigate, 'navigate');
|
||||
},
|
||||
|
||||
select: function(server, channel = null) {
|
||||
@ -60,7 +62,18 @@ var selectedTabStore = Reflux.createStore({
|
||||
},
|
||||
|
||||
loadChannels: function(channels) {
|
||||
// Handle double hashtag channel names, only a single hashtag
|
||||
// gets added to the channel in the URL on page load
|
||||
_.each(channels, (channel) => {
|
||||
if (channel.server === selectedTab.server &&
|
||||
channel.name !== selectedTab.channel &&
|
||||
channel.name.indexOf(selectedTab.channel) !== -1) {
|
||||
selectedTab.channel = channel.name;
|
||||
selectedTab.name = channel.name;
|
||||
|
||||
this.trigger(selectedTab);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
loadServers: function(servers) {
|
||||
@ -75,6 +88,14 @@ var selectedTabStore = Reflux.createStore({
|
||||
}
|
||||
},
|
||||
|
||||
navigate: function(route) {
|
||||
if (route.indexOf('.') === -1) {
|
||||
selectedTab.server = null;
|
||||
selectedTab.channel = null;
|
||||
this.trigger(selectedTab);
|
||||
}
|
||||
},
|
||||
|
||||
getServer: function() {
|
||||
return selectedTab.server;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user