/cycle command #444
authorDarren <darren@darrenwhitlen.com>
Fri, 27 Jun 2014 22:47:14 +0000 (23:47 +0100)
committerDarren <darren@darrenwhitlen.com>
Fri, 27 Jun 2014 22:47:14 +0000 (23:47 +0100)
client/src/misc/clientuicommands.js

index 935a89a2f11c81052ff4afd0a577c831b5678c6a..dd2adc827fe11809777642b401b164af373d5ee9 100644 (file)
@@ -65,6 +65,7 @@
         'command:action':      actionCommand,
         'command:join':        joinCommand,
         'command:part':        partCommand,
+        'command:cycle':        cycleCommand,
         'command:nick':        nickCommand,
         'command:query':       queryCommand,
         'command:invite':      inviteCommand,
     }
 
 
+    function cycleCommand (ev) {
+        var that = this,
+            chan_name;
+
+        if (ev.params.length === 0) {
+            chan_name = this.app.panels().active.get('name');
+        } else {
+            chan_name = ev.params[0];
+        }
+
+        this.app.connections.active_connection.gateway.part(chan_name);
+
+        // Wait for a second to give the network time to register the part command
+        setTimeout(function() {
+            // Use createAndJoinChannels() here as it auto-creates panels instead of waiting for the network
+            that.app.connections.active_connection.createAndJoinChannels(chan_name);
+            that.app.connections.active_connection.panels.getByName(chan_name).show();
+        }, 1000);
+    }
+
+
     function nickCommand (ev) {
         this.app.connections.active_connection.gateway.changeNick(ev.params[0]);
     }