Merge pull request #2094 from mattermost/GIT-1812
GIT-1812 fixing wesocket issue with firefox
Этот коммит содержится в:
@@ -28,10 +28,13 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
this.addChangeListener = this.addChangeListener.bind(this);
|
this.addChangeListener = this.addChangeListener.bind(this);
|
||||||
this.removeChangeListener = this.removeChangeListener.bind(this);
|
this.removeChangeListener = this.removeChangeListener.bind(this);
|
||||||
this.sendMessage = this.sendMessage.bind(this);
|
this.sendMessage = this.sendMessage.bind(this);
|
||||||
|
this.close = this.close.bind(this);
|
||||||
|
|
||||||
this.failCount = 0;
|
this.failCount = 0;
|
||||||
|
|
||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
if (!UserStore.getCurrentId()) {
|
if (!UserStore.getCurrentId()) {
|
||||||
return;
|
return;
|
||||||
@@ -106,15 +109,19 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emitChange(msg) {
|
emitChange(msg) {
|
||||||
this.emit(CHANGE_EVENT, msg);
|
this.emit(CHANGE_EVENT, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
addChangeListener(callback) {
|
addChangeListener(callback) {
|
||||||
this.on(CHANGE_EVENT, callback);
|
this.on(CHANGE_EVENT, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeChangeListener(callback) {
|
removeChangeListener(callback) {
|
||||||
this.removeListener(CHANGE_EVENT, callback);
|
this.removeListener(CHANGE_EVENT, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMessage(msg) {
|
handleMessage(msg) {
|
||||||
switch (msg.action) {
|
switch (msg.action) {
|
||||||
case SocketEvents.POSTED:
|
case SocketEvents.POSTED:
|
||||||
@@ -153,6 +160,7 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(msg) {
|
sendMessage(msg) {
|
||||||
if (conn && conn.readyState === WebSocket.OPEN) {
|
if (conn && conn.readyState === WebSocket.OPEN) {
|
||||||
conn.send(JSON.stringify(msg));
|
conn.send(JSON.stringify(msg));
|
||||||
@@ -161,9 +169,16 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
this.initialize();
|
this.initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setTranslations(messages) {
|
setTranslations(messages) {
|
||||||
this.translations = messages;
|
this.translations = messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
if (conn && conn.readyState === WebSocket.OPEN) {
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleNewPostEvent(msg, translations) {
|
function handleNewPostEvent(msg, translations) {
|
||||||
@@ -305,12 +320,5 @@ function handlePreferenceChangedEvent(msg) {
|
|||||||
|
|
||||||
var SocketStore = new SocketStoreClass();
|
var SocketStore = new SocketStoreClass();
|
||||||
|
|
||||||
/*SocketStore.dispatchToken = AppDispatcher.register((payload) => {
|
|
||||||
var action = payload.action;
|
|
||||||
|
|
||||||
switch (action.type) {
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
export default SocketStore;
|
export default SocketStore;
|
||||||
|
window.SocketStore = SocketStore;
|
||||||
|
|||||||
@@ -122,6 +122,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(window).on('beforeunload', function(){
|
||||||
|
if (window.SocketStore) {
|
||||||
|
SocketStore.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user