From 09cbe8c9e4bf636071dba0a60c29707ad1a5100d Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 1 Feb 2016 23:21:50 +0100 Subject: [PATCH] Fix the autoupdate --- openslides/core/static/js/core/base.js | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 7b32c531c..776aa9188 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -43,6 +43,15 @@ angular.module('OpenSlidesApp.core', [ var recInterval = null; $rootScope.connected = true; + var Autoupdate = { + messageReceivers: [], + onMessage: function (receiver) { + this.messageReceivers.push(receiver); + }, + reconnect: function () { + socket.close(); + } + }; var newConnect = function () { socket = new SockJS(location.origin + "/sockjs"); clearInterval(recInterval); @@ -56,25 +65,14 @@ angular.module('OpenSlidesApp.core', [ newConnect(); }, 1000); }; + socket.onmessage = function (event) { + _.forEach(Autoupdate.messageReceivers, function (receiver) { + receiver(event.data); + }); + }; }; - var Autoupdate = { - messageReceivers: [], - connect: function () { - socket.onmessage = function (event) { - _.forEach(Autoupdate.messageReceivers, function (receiver) { - receiver(event.data); - }); - }; - }, - on_message: function (receiver) { - this.messageReceivers.push(receiver); - }, - reconnect: function () { - socket.close(); - } - }; + newConnect(); - Autoupdate.connect(); return Autoupdate; } ]) @@ -168,7 +166,7 @@ angular.module('OpenSlidesApp.core', [ 'autoupdate', 'dsEject', function (DS, autoupdate, dsEject) { - autoupdate.on_message(function(data) { + autoupdate.onMessage(function(data) { // TODO: when MODEL.find() is called after this // a new request is fired. This could be a bug in DS