issue: https://linear.app/comm/issue/ENG-4683/refactor-useservercall-step-1-refactor-fetching-data-from-state
We currently fetch some data from state using serverCallStateSelector, and then bind this data to callServerEndpoint. But with multiple keyservers we won't know which keyserver is going to be called. Instead we will
fetch a collection of shape { [keyserverID]: {cookie, urlPrefix, ...} } and eventually pass it to the returned function, which will extract the data it needs. This is not very memory intensive, since we can create a
selector with createSelector, which memoizes the result and returns the reference to the same object as long as the result doesn't change (even in different components).
Details
Details
Ran the selector, chcked that it returns the expected value, as defined by ServersCallState.
ran yarn flow-all
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Branch
- inka/actions
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Comment Actions
Not sure how these will be used, but I'm wondering what is the benefit of having a selector returning
type ServersCallState = {
+cookies: { +[keyserverID: string]: ?string },
+urlPrefixes: { +[keyserverID: string]: string },
+sessionIDs: { +[keyserverID: string]: ?string },
+connectionStatuses: { +[keyserverID: string]: ConnectionStatus },
+lastCommunicatedPlatformDetails: {
+[keyserverID: string]: ?PlatformDetails,
},
+currentUserInfo: ?CurrentUserInfo,
};over a simpler selector that could return
{ +[keyserverID: string]: KeyserverInfo }where
type KeyserverInfo = {
+cookie?: ?string,
+sessionID?: ?string,
+updatesCurrentAsOf: number,
+urlPrefix: string,
+connection: ConnectionInfo,
};From the caller's point of view, the difference doesn't seem to be significant, e.g.
result.cookies[serverID]
vs
result[serverID].cookie
But I'm probably missing something.
Comment Actions
You are probably right, there isn't much more data in the keyserverInfos than we are fetching here, so this is probably unnecessary.