Page MenuHomePhabricator

D10844.diff
No OneTemporary

D10844.diff

diff --git a/lib/components/keyserver-connection-handler.js b/lib/components/keyserver-connection-handler.js
--- a/lib/components/keyserver-connection-handler.js
+++ b/lib/components/keyserver-connection-handler.js
@@ -24,6 +24,7 @@
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
+import sleep from '../utils/sleep.js';
import { ashoatKeyserverID } from '../utils/validation-utils.js';
type Props = {
@@ -31,6 +32,9 @@
+keyserverID: string,
+socketComponent: React.ComponentType<BaseSocketProps>,
};
+
+const AUTH_RETRY_DELAY_MS = 60_000;
+
function KeyserverConnectionHandler(props: Props) {
const { socketComponent: Socket, keyserverID, ...rest } = props;
@@ -81,18 +85,18 @@
const olmSessionCreator = React.useContext(OlmSessionCreatorContext);
invariant(olmSessionCreator, 'Olm session creator should be set');
- const authInProgress = React.useRef(false);
+ const [canPerformAuth, setCanPerformAuth] = React.useState(true);
const isUserAuthenticated = useSelector(isLoggedInToKeyserver(keyserverID));
React.useEffect(() => {
if (
!usingCommServicesAccessToken ||
- authInProgress.current ||
+ !canPerformAuth ||
isUserAuthenticated
) {
return;
}
- authInProgress.current = true;
+ setCanPerformAuth(false);
void (async () => {
try {
@@ -148,7 +152,8 @@
await dispatchActionPromise(logOutActionTypes, callLogOut());
}
} finally {
- authInProgress.current = false;
+ await sleep(AUTH_RETRY_DELAY_MS);
+ setCanPerformAuth(true);
}
})();
}, [
@@ -164,6 +169,7 @@
isUserAuthenticated,
callLogOut,
dataLoaded,
+ canPerformAuth,
]);
if (keyserverID !== ashoatKeyserverID) {

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 7:13 AM (20 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2589312
Default Alt Text
D10844.diff (1 KB)

Event Timeline