Page MenuHomePhabricator

D9710.diff
No OneTemporary

D9710.diff

diff --git a/lib/socket/api-request-handler.react.js b/lib/socket/api-request-handler.react.js
--- a/lib/socket/api-request-handler.react.js
+++ b/lib/socket/api-request-handler.react.js
@@ -27,7 +27,7 @@
+connection: ConnectionInfo,
};
class APIRequestHandler extends React.PureComponent<Props> {
- static isConnected(props: Props, request?: APIRequest) {
+ static isConnected(props: Props, request?: APIRequest): boolean {
const { inflightRequests, connection } = props;
if (!inflightRequests) {
return false;
@@ -45,11 +45,11 @@
// will be a great way to rewrite them to be related but still separated.
return (
connection.status === 'connected' ||
- (request && request.endpoint === 'update_activity')
+ request?.endpoint === 'update_activity'
);
}
- get registeredResponseFetcher() {
+ get registeredResponseFetcher(): ?(request: APIRequest) => Promise<mixed> {
return APIRequestHandler.isConnected(this.props)
? this.fetchResponse
: null;
@@ -71,11 +71,11 @@
}
}
- render() {
+ render(): React.Node {
return null;
}
- fetchResponse = async (request: APIRequest): Promise<Object> => {
+ fetchResponse = async (request: APIRequest): Promise<mixed> => {
if (!APIRequestHandler.isConnected(this.props, request)) {
throw new SocketOffline('socket_offline');
}
diff --git a/lib/socket/calendar-query-handler.react.js b/lib/socket/calendar-query-handler.react.js
--- a/lib/socket/calendar-query-handler.react.js
+++ b/lib/socket/calendar-query-handler.react.js
@@ -82,11 +82,11 @@
}
}
- render() {
+ render(): React.Node {
return null;
}
- get isExpired() {
+ get isExpired(): boolean {
const timeUntilExpiration = timeUntilCalendarRangeExpiration(
this.props.lastUserInteractionCalendar,
);
@@ -97,7 +97,7 @@
);
}
- get shouldUpdateCalendarQuery() {
+ get shouldUpdateCalendarQuery(): boolean {
if (this.props.connection.status !== 'connected' || this.props.frozen) {
return false;
}
diff --git a/lib/socket/inflight-requests.js b/lib/socket/inflight-requests.js
--- a/lib/socket/inflight-requests.js
+++ b/lib/socket/inflight-requests.js
@@ -104,11 +104,9 @@
};
}
});
- invariant(
- inflightRequest,
- `${expectedType} is an invalid server response type`,
- );
- this.data.push(inflightRequest);
+ const request = inflightRequest;
+ invariant(request, `${expectedType} is an invalid server response type`);
+ this.data.push(request);
// We create this object so we can pass it by reference to the timeout
// function below. That function will avoid setting this request as late if
@@ -124,12 +122,12 @@
if (requestResult.lateResponse) {
this.setLateResponse(messageID, false);
}
- this.clearRequest(inflightRequest);
+ this.clearRequest(request);
// Flow is unable to narrow the return type based on the expectedType
return (response: any);
} catch (e) {
requestResult.concluded = true;
- this.clearRequest(inflightRequest);
+ this.clearRequest(request);
if (e instanceof SocketTimeout) {
this.rejectAll(new Error('socket closed due to timeout'));
this.timeoutCallback();
@@ -144,7 +142,7 @@
messageID: number,
expectedType: ServerSocketMessageType,
requestResult: { concluded: boolean, lateResponse: boolean },
- ) {
+ ): Promise<void> {
await sleep(clientRequestVisualTimeout);
if (requestResult.concluded) {
// We're just doing this to bail out. If requestResult.concluded we can
diff --git a/lib/socket/report-handler.react.js b/lib/socket/report-handler.react.js
--- a/lib/socket/report-handler.react.js
+++ b/lib/socket/report-handler.react.js
@@ -52,7 +52,7 @@
}
}
- render() {
+ render(): React.Node {
return null;
}
@@ -66,9 +66,11 @@
);
}
- async sendReports(reports: $ReadOnlyArray<ClientReportCreationRequest>) {
+ async sendReports(
+ reports: $ReadOnlyArray<ClientReportCreationRequest>,
+ ): Promise<ClearDeliveredReportsPayload> {
await sendReports(reports);
- return ({ reports }: ClearDeliveredReportsPayload);
+ return { reports };
}
}
diff --git a/lib/socket/request-response-handler.react.js b/lib/socket/request-response-handler.react.js
--- a/lib/socket/request-response-handler.react.js
+++ b/lib/socket/request-response-handler.react.js
@@ -49,7 +49,7 @@
this.props.removeListener(this.onMessage);
}
- render() {
+ render(): React.Node {
return null;
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 8:37 AM (11 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2704627
Default Alt Text
D9710.diff (4 KB)

Event Timeline