Page MenuHomePhabricator

D10973.diff
No OneTemporary

D10973.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,10 @@
const socket = React.useRef<?WebSocket>(null);
const heartbeatTimeoutID = React.useRef<?TimeoutID>();
+ const previousAuthMessage = React.useRef<?IdentitySearchAuthMessage>(
+ identitySearchAuthMessage,
+ );
+
const stopHeartbeatTimeout = React.useCallback(() => {
if (heartbeatTimeoutID.current) {
clearTimeout(heartbeatTimeoutID.current);
@@ -65,6 +69,22 @@
}, [getIdentitySearchAuthMessage]);
React.useEffect(() => {
+ const isSocketActive =
+ socket.current?.readyState === WebSocket.OPEN ||
+ socket.current?.readyState === WebSocket.CONNECTING;
+
+ const identitySearchAuthMessageChanged =
+ identitySearchAuthMessage !== previousAuthMessage.current;
+ previousAuthMessage.current = identitySearchAuthMessage;
+
+ if (
+ (!identitySearchAuthMessage || identitySearchAuthMessageChanged) &&
+ isSocketActive
+ ) {
+ socket.current?.close();
+ return;
+ }
+
if (connected || !identitySearchAuthMessage) {
return;
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 2:15 AM (19 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675063
Default Alt Text
D10973.diff (1 KB)

Event Timeline