Page MenuHomePhabricator

D10973.id37416.diff
No OneTemporary

D10973.id37416.diff

diff --git a/lib/identity-search/identity-search-context.js b/lib/identity-search/identity-search-context.js
--- a/lib/identity-search/identity-search-context.js
+++ b/lib/identity-search/identity-search-context.js
@@ -42,6 +42,9 @@
const socket = React.useRef<?WebSocket>(null);
const heartbeatTimeoutID = React.useRef<?TimeoutID>();
+ const previousIdentitySearchAuthMessage =
+ React.useRef<?IdentitySearchAuthMessage>(identitySearchAuthMessage);
+
const stopHeartbeatTimeout = React.useCallback(() => {
if (heartbeatTimeoutID.current) {
clearTimeout(heartbeatTimeoutID.current);
@@ -65,6 +68,22 @@
}, [getIdentitySearchAuthMessage]);
React.useEffect(() => {
+ const isSocketActive =
+ socket.current?.readyState === WebSocket.OPEN ||
+ socket.current?.readyState === WebSocket.CONNECTING;
+
+ const identitySearchAuthMessageChanged =
+ identitySearchAuthMessage !== previousIdentitySearchAuthMessage.current;
+ previousIdentitySearchAuthMessage.current = identitySearchAuthMessage;
+
+ if (
+ (!identitySearchAuthMessage || identitySearchAuthMessageChanged) &&
+ isSocketActive
+ ) {
+ socket.current?.close();
+ return;
+ }
+
if (connected || !identitySearchAuthMessage) {
return;
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 3:51 AM (20 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675161
Default Alt Text
D10973.id37416.diff (1 KB)

Event Timeline