Skip to content

Commit

Permalink
fix: sending browsersetting update after reconnect fails
Browse files Browse the repository at this point in the history
- global.socket instance is not updated after reconnection therefore
state shown when sending browsersettings using global.socket.send is
from previous instance of websocket

Signed-off-by: Rashesh <[email protected]>
Change-Id: Ie07cf1c98ea8b3e27575348deba938a2bdf15663
  • Loading branch information
Rash419 authored and caolanm committed Jan 27, 2025
1 parent 0c30835 commit 0b9f857
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion browser/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ function getInitializerClass() {
value = String(value); // NOT "new String(...)". We cannot use .toString here because value could be null/undefined
if (global.prefs.useBrowserSetting) {
global.prefs._userBrowserSetting[key] = value;
global.socket.send('browsersetting action=update key=' + key + ' value=' + value);
if (global.socket && (global.socket instanceof WebSocket) && global.socket.readyState === 1)
global.socket.send('browsersetting action=update key=' + key + ' value=' + value);
}
if (global.prefs.canPersist) {
global.localStorage.setItem(key, value);
Expand Down
1 change: 1 addition & 0 deletions browser/src/core/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ app.definitions.Socket = L.Class.extend({
} else {
try {
this.socket = window.createWebSocket(this.getWebSocketBaseURI(map));
window.socket = this.socket;
} catch (e) {
this._map.fire('error', {msg: _('Oops, there is a problem connecting to {productname}: ').replace('{productname}', (typeof brandProductName !== 'undefined' ? brandProductName : 'Collabora Online Development Edition (unbranded)')) + e, cmd: 'socket', kind: 'failed', id: 3});
return;
Expand Down

0 comments on commit 0b9f857

Please sign in to comment.