Merge pull request #1806 from ostcar/fix_autoupdate_after_reload
Fix autoupdate after auth
This commit is contained in:
commit
544efdb06e
@ -30,33 +30,42 @@ angular.module('OpenSlidesApp.core', [
|
||||
DSHttpAdapterProvider.defaults.forceTrailingSlash = true;
|
||||
}])
|
||||
|
||||
.factory('autoupdate', function() {
|
||||
.factory('autoupdate', [
|
||||
'DS',
|
||||
function (DS) {
|
||||
var url = location.origin + "/sockjs";
|
||||
|
||||
var socket;
|
||||
var Autoupdate = {
|
||||
socket: null,
|
||||
message_receivers: [],
|
||||
connect: function() {
|
||||
connect: function () {
|
||||
var autoupdate = this;
|
||||
this.socket = new SockJS(url);
|
||||
socket = this.socket = new SockJS(url);
|
||||
|
||||
this.socket.onmessage = function(event) {
|
||||
_.forEach(autoupdate.message_receivers, function(receiver) {
|
||||
|
||||
this.socket.onmessage = function (event) {
|
||||
_.forEach(autoupdate.message_receivers, function (receiver) {
|
||||
receiver(event.data);
|
||||
});
|
||||
};
|
||||
|
||||
this.socket.onclose = function() {
|
||||
this.socket.onclose = function () {
|
||||
setTimeout(autoupdate.connect, 5000);
|
||||
};
|
||||
},
|
||||
on_message: function(receiver) {
|
||||
on_message: function (receiver) {
|
||||
this.message_receivers.push(receiver);
|
||||
},
|
||||
reconnect: function () {
|
||||
socket.close();
|
||||
DS.clear();
|
||||
Autoupdate.connect();
|
||||
}
|
||||
};
|
||||
Autoupdate.connect();
|
||||
return Autoupdate;
|
||||
})
|
||||
}
|
||||
])
|
||||
|
||||
.run(['DS', 'autoupdate', function(DS, autoupdate) {
|
||||
autoupdate.on_message(function(data) {
|
||||
|
@ -8,8 +8,9 @@ angular.module('OpenSlidesApp.users', [])
|
||||
'User',
|
||||
'Group',
|
||||
'loadGlobalData',
|
||||
function(User, Group, loadGlobalData) {
|
||||
var operatorChangeCallbacks = [];
|
||||
'autoupdate',
|
||||
function (User, Group, loadGlobalData, autoupdate) {
|
||||
var operatorChangeCallbacks = [autoupdate.reconnect];
|
||||
var operator = {
|
||||
user: null,
|
||||
perms: [],
|
||||
@ -33,6 +34,10 @@ angular.module('OpenSlidesApp.users', [])
|
||||
});
|
||||
} else {
|
||||
operator.user = null;
|
||||
operator.perms = [];
|
||||
_.forEach(operatorChangeCallbacks, function (callback) {
|
||||
callback();
|
||||
});
|
||||
Group.find(1).then(function(group) {
|
||||
operator.perms = group.permissions;
|
||||
_.forEach(operatorChangeCallbacks, function (callback) {
|
||||
|
Loading…
Reference in New Issue
Block a user