Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3372596
D10844.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10844.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D10844: [lib] Retry auth
Attached
Detach File
Event Timeline
Log In to Comment