Skip to content

Commit

Permalink
Merge branch 'ws-better-reco' into 'master'
Browse files Browse the repository at this point in the history
connect ws if disconnected in sendMessage handler

See merge request kchat/webapp!545
  • Loading branch information
antonbuks committed Oct 6, 2023
2 parents 8279c35 + 34446a7 commit e4262e0
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/client/src/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,17 @@ export default class WebSocketClient {
} else if (!this.conn || this.conn.connection.state === 'disconnected') {
console.log('[websocket] tried to send message but connection unavailable');

// Sentry.captureException(new Error('Websocket tried to send message but connection unavailable'));

// this.conn = null;
this.conn?.disconnect();
this.conn = null;

// //@ts-ignore
// this.initialize(this.connectionId, this.currentUser as number, this.currentTeam, undefined, localStorage.getItem('IKToken'), this.currentPresence);
this.initialize(
this.connectionUrl,
this.currentUser as number,
this.currentTeamUser,
this.currentTeam,
localStorage.getItem('IKToken') as string,
this.currentPresence,
);
}
}

Expand All @@ -577,11 +582,19 @@ export default class WebSocketClient {
this.presenceChannel?.trigger(action, msg);
} else if (!this.conn || this.conn.connection.state === 'disconnected' || !this.presenceChannel) {
console.log('presence channel is missing');
console.log('connection: ', this.conn);
console.log('connection state: ', this.conn?.connection.state);
console.log('presence channel: ', this.presenceChannel);

// this.bindPresenceChannel(data.channel_id);
this.conn?.disconnect();
this.conn = null;

this.initialize(
this.connectionUrl,
this.currentUser as number,
this.currentTeamUser,
this.currentTeam,
localStorage.getItem('IKToken') as string,
this.currentPresence,
);
}
}

Expand Down

0 comments on commit e4262e0

Please sign in to comment.