From c16e8d603be37aeca706e0c25dcc56d1fd04da6c Mon Sep 17 00:00:00 2001
From: yflory <yann.flory@xwiki.com>
Date: Mon, 26 Sep 2016 16:06:23 +0200
Subject: [PATCH] Enable reconnecting websocket in code pad

---
 www/code/main.js | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/www/code/main.js b/www/code/main.js
index 6fffd26ec..1fb389e8a 100644
--- a/www/code/main.js
+++ b/www/code/main.js
@@ -703,9 +703,22 @@ define([
             var onAbort = config.onAbort = function (info) {
                 // inform of network disconnect
                 setEditable(false);
+                toolbar.failed();
                 Cryptpad.alert(Messages.disconnectAlert);
             };
 
+            var onConnectionChange = config.onConnectionChange = function (info) {
+                setEditable(info.state);
+                toolbar.failed();
+                if (info.state) {
+                    initializing = true;
+                    toolbar.reconnecting(info.myId);
+                    Cryptpad.findOKButton().click();
+                } else {
+                    Cryptpad.alert(Messages.disconnectAlert);
+                }
+            };
+
             var realtime = module.realtime = Realtime.start(config);
 
             editor.on('change', onLocal);