function allCommands (ev) {}\r
\r
function joinCommand (ev) {\r
- var channel, channel_names;\r
+ var panels, channel_names;\r
\r
channel_names = ev.params.join(' ').split(',');\r
+ panels = that.connections.active_connection.createAndJoinChannels(channel_names);\r
\r
- $.each(channel_names, function (index, channel_name_key) {\r
- // We may have a channel key so split it off\r
- var spli = channel_name_key.split(' '),\r
- channel_name = spli[0],\r
- channel_key = spli[1] || '';\r
-\r
- // Trim any whitespace off the name\r
- channel_name = channel_name.trim();\r
-\r
- // If not a valid channel name, display a warning\r
- if (!that.isChannelName(channel_name)) {\r
- _kiwi.app.panels().server.addMsg('', channel_name + ' is not a valid channel name');\r
- _kiwi.app.message.text(channel_name + ' is not a valid channel name', {timeout: 5000});\r
- return;\r
- }\r
-\r
- // Check if we have the panel already. If not, create it\r
- channel = that.connections.active_connection.panels.getByName(channel_name);\r
- if (!channel) {\r
- channel = new _kiwi.model.Channel({name: channel_name});\r
- _kiwi.app.connections.active_connection.panels.add(channel);\r
- }\r
-\r
- _kiwi.gateway.join(channel_name, channel_key);\r
- });\r
-\r
- if (channel) channel.view.show();\r
- \r
+ // Show the last channel if we have one\r
+ if (panels)\r
+ panels[panels.length - 1].view.show();\r
}\r
\r
function queryCommand (ev) {\r
};\r
\r
\r
-\r
- this.eachPanel = function (fn) {\r
- alert('Switch this call with _kiwi.app.panels! location in console.log');\r
- console.log('Switch this call with _kiwi.app.panels! location in console.log');\r
- if (typeof fn !== 'function')\r
- return;\r
-\r
- _.each(this.connections.models, function(connection) {\r
- _.each(connection.panels.model, fn);\r
- });\r
- };\r
-\r
};\r
\r
\r
this.gateway.on('whois', onWhois, this);
this.gateway.on('away', onAway, this);
this.gateway.on('list_start', onListStart, this);
+ },
+
+
+ /**
+ * Create panels and join the channel
+ * This will not wait for the join event to create a panel. This
+ * increases responsiveness in case of network lag
+ */
+ createAndJoinChannels: function (channels) {
+ var that = this,
+ panels = [];
+
+ // Multiple channels may come as comma-delimited
+ if (typeof channels === 'string') {
+ channels = channels.split(',');
+ }
+
+ $.each(channels, function (index, channel_name_key) {
+ // We may have a channel key so split it off
+ var spli = channel_name_key.trim().split(' '),
+ channel_name = spli[0],
+ channel_key = spli[1] || '';
+
+ // Trim any whitespace off the name
+ channel_name = channel_name.trim();
+
+ // If not a valid channel name, display a warning
+ if (!_kiwi.app.isChannelName(channel_name)) {
+ that.panels.server.addMsg('', channel_name + ' is not a valid channel name');
+ _kiwi.app.message.text(channel_name + ' is not a valid channel name', {timeout: 5000});
+ return;
+ }
+
+ // Check if we have the panel already. If not, create it
+ channel = that.panels.getByName(channel_name);
+ if (!channel) {
+ channel = new _kiwi.model.Channel({name: channel_name});
+ that.panels.add(channel);
+ }
+
+ panels.push(channel);
+
+ that.gateway.join(channel_name, channel_key);
+ });
+
+ return panels;
}
});
function onConnect(event) {
+ var panels, channel_names;
+
+ // Update our nick with what the network gave us
this.set('nick', event.nick);
+ // Auto joining channels
if (this.auto_join && this.auto_join.channel) {
- this.gateway.join(this.auto_join.channel, this.auto_join.channel_key);
+ panels = this.createAndJoinChannels(this.auto_join.channel + ' ' + (this.auto_join.channel_key || ''));
+
+ // Show the last channel if we have one
+ if (panels)
+ panels[panels.length - 1].view.show();
}
}