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) => {
|
tabActions.select.preEmit = (server, channel) => {
|
||||||
if (channel) {
|
if (channel) {
|
||||||
routeActions.navigate('/' + server + '/' + channel.slice(1))
|
while (channel[0] === '#') {
|
||||||
|
channel = channel.slice(1);
|
||||||
|
}
|
||||||
|
routeActions.navigate('/' + server + '/' + channel);
|
||||||
} else {
|
} else {
|
||||||
routeActions.navigate('/' + server);
|
routeActions.navigate('/' + server);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ var Chat = React.createClass({
|
|||||||
mixins: [Router.State],
|
mixins: [Router.State],
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
if (!window.loaded) {
|
||||||
var p = this.getParams();
|
var p = this.getParams();
|
||||||
|
|
||||||
if (p.channel) {
|
if (p.channel) {
|
||||||
@ -19,6 +20,7 @@ var Chat = React.createClass({
|
|||||||
} else if (p.server) {
|
} else if (p.server) {
|
||||||
tabActions.select(p.server);
|
tabActions.select(p.server);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -6,6 +6,7 @@ var channelActions = require('./actions/channel');
|
|||||||
var messageActions = require('./actions/message');
|
var messageActions = require('./actions/message');
|
||||||
var serverActions = require('./actions/server');
|
var serverActions = require('./actions/server');
|
||||||
var routeActions = require('./actions/route');
|
var routeActions = require('./actions/route');
|
||||||
|
var tabActions = require('./actions/tab');
|
||||||
|
|
||||||
socket.on('join', function(data) {
|
socket.on('join', function(data) {
|
||||||
channelActions.addUser(data.user, data.server, data.channels[0]);
|
channelActions.addUser(data.user, data.server, data.channels[0]);
|
||||||
@ -71,9 +72,12 @@ socket.on('whois', function(data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('servers', function(data) {
|
socket.on('servers', function(data) {
|
||||||
|
window.loaded = true;
|
||||||
|
|
||||||
if (data === null) {
|
if (data === null) {
|
||||||
routeActions.navigate('connect');
|
routeActions.navigate('connect');
|
||||||
}
|
}
|
||||||
|
|
||||||
serverActions.load(data);
|
serverActions.load(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ var serverStore = require('./server');
|
|||||||
var actions = require('../actions/tab');
|
var actions = require('../actions/tab');
|
||||||
var channelActions = require('../actions/channel');
|
var channelActions = require('../actions/channel');
|
||||||
var serverActions = require('../actions/server');
|
var serverActions = require('../actions/server');
|
||||||
|
var routeActions = require('../actions/route');
|
||||||
|
|
||||||
var selectedTab = {};
|
var selectedTab = {};
|
||||||
|
|
||||||
@ -14,8 +15,9 @@ var selectedTabStore = Reflux.createStore({
|
|||||||
this.listenTo(channelActions.part, 'part');
|
this.listenTo(channelActions.part, 'part');
|
||||||
this.listenTo(serverActions.disconnect, 'disconnect');
|
this.listenTo(serverActions.disconnect, 'disconnect');
|
||||||
this.listenTo(channelActions.addUser, 'userAdded');
|
this.listenTo(channelActions.addUser, 'userAdded');
|
||||||
//this.listenTo(channelActions.load, 'loadChannels');
|
this.listenTo(channelActions.load, 'loadChannels');
|
||||||
this.listenTo(serverActions.load, 'loadServers');
|
this.listenTo(serverActions.load, 'loadServers');
|
||||||
|
this.listenTo(routeActions.navigate, 'navigate');
|
||||||
},
|
},
|
||||||
|
|
||||||
select: function(server, channel = null) {
|
select: function(server, channel = null) {
|
||||||
@ -60,7 +62,18 @@ var selectedTabStore = Reflux.createStore({
|
|||||||
},
|
},
|
||||||
|
|
||||||
loadChannels: function(channels) {
|
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) {
|
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() {
|
getServer: function() {
|
||||||
return selectedTab.server;
|
return selectedTab.server;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user