Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32314278
D12219.1765297399.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D12219.1765297399.diff
View Options
diff --git a/lib/handlers/user-infos-handler.react.js b/lib/handlers/user-infos-handler.react.js
--- a/lib/handlers/user-infos-handler.react.js
+++ b/lib/handlers/user-infos-handler.react.js
@@ -2,6 +2,11 @@
import * as React from 'react';
+import {
+ useFindUserIdentities,
+ findUserIdentitiesActionTypes,
+} from '../actions/user-actions.js';
+import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
import {
relyingOnAuthoritativeKeyserver,
@@ -18,17 +23,46 @@
return Object.fromEntries(entriesWithoutUsernames);
}, [userInfos]);
+ const dispatchActionPromise = useDispatchActionPromise();
+ const findUserIdentities = useFindUserIdentities();
+
+ const requestedIDsRef = React.useRef(new Set<string>());
+
React.useEffect(() => {
- if (!usingCommServicesAccessToken) {
+ const newUserIDs = Object.keys(userInfosWithMissingUsernames).filter(
+ id => !requestedIDsRef.current.has(id),
+ );
+ if (!usingCommServicesAccessToken || newUserIDs.length === 0) {
return;
}
- // 1. TODO: fetch usernames from identity
- // 2. Fetch avatars and settings from auth keyserver
- if (relyingOnAuthoritativeKeyserver) {
- // TODO
- }
- }, [userInfosWithMissingUsernames]);
+ const promise = (async () => {
+ newUserIDs.forEach(id => requestedIDsRef.current.add(id));
+ // 1. Fetch usernames from identity
+ const identities = await findUserIdentities(newUserIDs);
+
+ // 2. Fetch avatars and settings from auth keyserver
+ if (relyingOnAuthoritativeKeyserver) {
+ // TODO
+ }
+ newUserIDs.forEach(id => requestedIDsRef.current.delete(id));
+
+ const newUserInfos = [];
+ for (const id in identities) {
+ newUserInfos.push({
+ id,
+ username: identities[id].username,
+ });
+ }
+ return { userInfos: newUserInfos };
+ })();
+ void dispatchActionPromise(findUserIdentitiesActionTypes, promise);
+ }, [
+ dispatchActionPromise,
+ findUserIdentities,
+ userInfos,
+ userInfosWithMissingUsernames,
+ ]);
}
export { UserInfosHandler };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 9, 4:23 PM (2 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5854062
Default Alt Text
D12219.1765297399.diff (2 KB)
Attached To
Mode
D12219: [lib] Fetch missing usernames
Attached
Detach File
Event Timeline
Log In to Comment