@@ -7,7 +7,7 @@ let is_reconnecting = false
77let last_ping_timestamp = Date . now ( )
88
99browser . storage . onChanged . addListener ( ( changes , areaName ) => {
10- if ( areaName == 'local' && changes [ 'browser-profile-name' ] ) {
10+ if ( areaName === 'local' && changes [ 'browser-profile-name' ] ) {
1111 if ( websocket ) {
1212 is_reconnecting = false
1313 const old_ws = websocket
@@ -28,7 +28,7 @@ export const check_server_health = async (): Promise<boolean> => {
2828}
2929
3030export const check_and_recover_connection = ( ) => {
31- if ( websocket ?. readyState == WebSocket . OPEN ) {
31+ if ( websocket ?. readyState === WebSocket . OPEN ) {
3232 if ( Date . now ( ) - last_ping_timestamp > 20000 ) {
3333 console . warn (
3434 'WebSocket connection is stale (no recent pings). Force reconnecting...'
@@ -40,8 +40,8 @@ export const check_and_recover_connection = () => {
4040
4141 if (
4242 ! is_reconnecting &&
43- websocket ?. readyState != WebSocket . OPEN &&
44- websocket ?. readyState != WebSocket . CONNECTING
43+ websocket ?. readyState !== WebSocket . OPEN &&
44+ websocket ?. readyState !== WebSocket . CONNECTING
4545 ) {
4646 connect_websocket ( )
4747 }
@@ -50,8 +50,8 @@ export const check_and_recover_connection = () => {
5050export const connect_websocket = async ( ) : Promise < void > => {
5151 if (
5252 is_reconnecting ||
53- websocket ?. readyState == WebSocket . OPEN ||
54- websocket ?. readyState == WebSocket . CONNECTING
53+ websocket ?. readyState === WebSocket . OPEN ||
54+ websocket ?. readyState === WebSocket . CONNECTING
5555 ) {
5656 return
5757 }
@@ -104,9 +104,9 @@ export const connect_websocket = async (): Promise<void> => {
104104 ws . onmessage = async ( event ) => {
105105 if ( websocket !== ws ) return
106106 const message = JSON . parse ( event . data )
107- if ( message . action == 'ping' ) {
107+ if ( message . action === 'ping' ) {
108108 last_ping_timestamp = Date . now ( )
109- if ( ws . readyState == WebSocket . OPEN ) {
109+ if ( ws . readyState === WebSocket . OPEN ) {
110110 ws . send ( JSON . stringify ( { action : 'pong' } ) )
111111 }
112112 return
@@ -137,7 +137,7 @@ export const connect_websocket = async (): Promise<void> => {
137137}
138138
139139export const send_message_to_server = ( message : any ) : boolean => {
140- if ( websocket ?. readyState == WebSocket . OPEN ) {
140+ if ( websocket ?. readyState === WebSocket . OPEN ) {
141141 websocket . send ( JSON . stringify ( message ) )
142142 return true
143143 }
0 commit comments