Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3536115
D10479.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10479.diff
View Options
diff --git a/lib/selectors/keyserver-selectors.js b/lib/selectors/keyserver-selectors.js
--- a/lib/selectors/keyserver-selectors.js
+++ b/lib/selectors/keyserver-selectors.js
@@ -82,6 +82,19 @@
const urlPrefixSelector: (keyserverID: string) => (state: AppState) => ?string =
_memoize(baseUrlPrefixSelector);
+const urlsToIDsSelector: (state: AppState) => {
+ +[url: string]: ?string,
+} = createSelector(
+ (state: AppState) => state.keyserverStore.keyserverInfos,
+ (infos: { +[key: string]: KeyserverInfo }) => {
+ const urlToIDs: { [string]: ?string } = {};
+ for (const keyserverID in infos) {
+ urlToIDs[infos[keyserverID].urlPrefix] = keyserverID;
+ }
+ return urlToIDs;
+ },
+);
+
const baseConnectionSelector: (
keyserverID: string,
) => (state: AppState) => ?ConnectionInfo = keyserverID => (state: AppState) =>
@@ -162,6 +175,7 @@
updatesCurrentAsOfSelector,
currentAsOfSelector,
urlPrefixSelector,
+ urlsToIDsSelector,
connectionSelector,
lastCommunicatedPlatformDetailsSelector,
deviceTokensSelector,
diff --git a/lib/shared/keyserver-utils.js b/lib/shared/keyserver-utils.js
--- a/lib/shared/keyserver-utils.js
+++ b/lib/shared/keyserver-utils.js
@@ -6,14 +6,35 @@
useGetVersion,
getVersionActionTypes,
} from '../actions/device-actions.js';
+import { urlsToIDsSelector } from '../selectors/keyserver-selectors.js';
import { useDispatchActionPromise } from '../utils/action-utils.js';
+import { useSelector } from '../utils/redux-utils.js';
function useIsKeyserverURLValid(keyserverURL?: string): () => Promise<boolean> {
+ const urlsToIDs: { +[keyserverID: string]: ?string } =
+ useSelector(urlsToIDsSelector);
+
+ const keyserverID: ?string = keyserverURL
+ ? urlsToIDs[keyserverURL]
+ : undefined;
+
+ const keyserverInfo = useSelector(state =>
+ keyserverID ? state.keyserverStore.keyserverInfos[keyserverID] : undefined,
+ );
+
const serverCallParamOverride = React.useMemo(() => {
if (!keyserverURL) {
return undefined;
}
+ if (keyserverInfo && keyserverID) {
+ return {
+ keyserverInfos: {
+ [(keyserverID: string)]: keyserverInfo,
+ },
+ };
+ }
+
return {
keyserverInfos: {
[(keyserverURL: string)]: {
@@ -21,7 +42,7 @@
},
},
};
- }, [keyserverURL]);
+ }, [keyserverID, keyserverInfo, keyserverURL]);
const getVersionCall = useGetVersion(serverCallParamOverride);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 26, 5:34 PM (11 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2707756
Default Alt Text
D10479.diff (2 KB)
Attached To
Mode
D10479: [lib] Fix unable to register new user
Attached
Detach File
Event Timeline
Log In to Comment