Skip to content

Commit

Permalink
[lib] Remove KeyserverInfoPartial type
Browse files Browse the repository at this point in the history
Summary:
Following the Flow upgrade, I'm looking at replacing all usages of `$Shape` in our codebase. Context [here](https://medium.com/flow-type/announcing-partial-required-flow-utility-types-catch-annotations-3a32f0bf2a20).

When I swapped the `$Shape` in `KeyserverInfoPartial` into a `Partial`, it revealed a type error. The issue is that the `urlPrefix` and `connectionStatus` we pass to `createBoundServerCallsSelector` are nullable, but that function requires them to be set.

I investigated further and found that we don't actually use `KeyserverInfoPartial` in any case where its "partialness" is necessary... it appears we just get the `KeyserverInfos` from the Redux store and pass them in. As such, I deleted the type and replaced usages with `KeyserverInfos`.

Depends on D10082

Test Plan: Flow

Reviewers: inka, michal

Reviewed By: inka

Subscribers: ginsu, tomek

Differential Revision: https://phab.comm.dev/D10083
  • Loading branch information
Ashoat committed Nov 30, 2023
1 parent 0f9ba51 commit 8106193
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/utils/keyserver-call.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ type CreateBoundServerCallsSelectorType = (
keyserverID: string,
) => BindServerCallsParams => CallServerEndpoint;
const createBoundServerCallsSelector: CreateBoundServerCallsSelectorType =
(_memoize(baseCreateBoundServerCallsSelector): any);
_memoize(baseCreateBoundServerCallsSelector);

export type KeyserverInfoPartial = $Shape<KeyserverInfo>;
type KeyserverInfoPartial = $ReadOnly<{
...Partial<KeyserverInfo>,
+urlPrefix: $PropertyType<KeyserverInfo, 'urlPrefix'>,
}>;

export type BindKeyserverCallParams = {
type BindKeyserverCallParams = {
+dispatch: Dispatch,
+currentUserInfo: ?CurrentUserInfo,
+keyserverInfos: { +[keyserverID: string]: KeyserverInfoPartial },
Expand All @@ -94,7 +97,7 @@ const bindCallKeyserverEndpointSelector: BindKeyserverCallParams => <
(
dispatch: Dispatch,
currentUserInfo: ?CurrentUserInfo,
keyserverInfos: { +[keyserverID: string]: KeyserverInfo },
keyserverInfos: { +[keyserverID: string]: KeyserverInfoPartial },
) => {
return _memoize(
<Args: mixed, Return>(
Expand Down Expand Up @@ -122,7 +125,7 @@ const bindCallKeyserverEndpointSelector: BindKeyserverCallParams => <
cookie,
urlPrefix,
sessionID,
connectionStatus: connection?.status,
connectionStatus: connection?.status ?? 'disconnected',
lastCommunicatedPlatformDetails,
keyserverID,
});
Expand Down

0 comments on commit 8106193

Please sign in to comment.