Page MenuHomePhabricator

D9044.diff
No OneTemporary

D9044.diff

diff --git a/lib/actions/report-actions.js b/lib/actions/report-actions.js
--- a/lib/actions/report-actions.js
+++ b/lib/actions/report-actions.js
@@ -11,33 +11,25 @@
success: 'SEND_REPORT_SUCCESS',
failed: 'SEND_REPORT_FAILED',
});
-const sendReport =
- (): ((
- request: ClientReportCreationRequest,
- ) => Promise<ReportCreationResponse>) =>
- async request => {
- const {
- reportIDs: [id],
- } = await callSendReports([request]);
- if (!id) {
- throw new Error('Server did not return report ID');
- }
- return { id };
- };
+const sendReport: (
+ request: ClientReportCreationRequest,
+) => Promise<ReportCreationResponse> = async request => {
+ const {
+ reportIDs: [id],
+ } = await callSendReports([request]);
+
+ if (!id) {
+ throw new Error('Server did not return report ID');
+ }
+ return { id };
+};
const sendReportsActionTypes = Object.freeze({
started: 'SEND_REPORTS_STARTED',
success: 'SEND_REPORTS_SUCCESS',
failed: 'SEND_REPORTS_FAILED',
});
-const sendReports =
- (): ((
- reports: $ReadOnlyArray<ClientReportCreationRequest>,
- ) => Promise<void>) =>
- async clientReports => {
- await callSendReports(clientReports);
- };
const queueReportsActionType = 'QUEUE_REPORTS';
@@ -45,6 +37,5 @@
sendReportActionTypes,
sendReport,
sendReportsActionTypes,
- sendReports,
queueReportsActionType,
};
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
@@ -2,10 +2,7 @@
import * as React from 'react';
-import {
- sendReportsActionTypes,
- sendReports,
-} from '../actions/report-actions.js';
+import { sendReportsActionTypes } from '../actions/report-actions.js';
import { queuedReports as queuedReportsSelector } from '../selectors/socket-selectors.js';
import {
type ClientReportCreationRequest,
@@ -14,9 +11,9 @@
import {
type DispatchActionPromise,
useDispatchActionPromise,
- useServerCall,
} from '../utils/action-utils.js';
import { useSelector } from '../utils/redux-utils.js';
+import { sendReports } from '../utils/reports-service.js';
type BaseProps = {
+canSendReports: boolean,
@@ -25,9 +22,6 @@
...BaseProps,
+queuedReports: $ReadOnlyArray<ClientReportCreationRequest>,
+dispatchActionPromise: DispatchActionPromise,
- +sendReports: (
- reports: $ReadOnlyArray<ClientReportCreationRequest>,
- ) => Promise<void>,
};
class ReportHandler extends React.PureComponent<Props> {
componentDidMount() {
@@ -73,7 +67,7 @@
}
async sendReports(reports: $ReadOnlyArray<ClientReportCreationRequest>) {
- await this.props.sendReports(reports);
+ await sendReports(reports);
return ({ reports }: ClearDeliveredReportsPayload);
}
}
@@ -81,14 +75,12 @@
const ConnectedReportHandler: React.ComponentType<BaseProps> =
React.memo<BaseProps>(function ConnectedReportHandler(props) {
const queuedReports = useSelector(queuedReportsSelector);
- const callSendReports = useServerCall(sendReports);
const dispatchActionPromise = useDispatchActionPromise();
return (
<ReportHandler
{...props}
queuedReports={queuedReports}
- sendReports={callSendReports}
dispatchActionPromise={dispatchActionPromise}
/>
);
diff --git a/native/crash.react.js b/native/crash.react.js
--- a/native/crash.react.js
+++ b/native/crash.react.js
@@ -21,12 +21,7 @@
import { logOutActionTypes, logOut } from 'lib/actions/user-actions.js';
import { preRequestUserStateSelector } from 'lib/selectors/account-selectors.js';
import type { LogOutResult } from 'lib/types/account-types.js';
-import {
- type ErrorData,
- type ClientReportCreationRequest,
- type ReportCreationResponse,
- reportTypes,
-} from 'lib/types/report-types.js';
+import { type ErrorData, reportTypes } from 'lib/types/report-types.js';
import type { PreRequestUserState } from 'lib/types/session-types.js';
import { actionLogger } from 'lib/utils/action-logger.js';
import {
@@ -63,9 +58,6 @@
// Redux dispatch functions
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
- +sendReport: (
- request: ClientReportCreationRequest,
- ) => Promise<ReportCreationResponse>,
+logOut: (preRequestUserState: PreRequestUserState) => Promise<LogOutResult>,
+crashReportingEnabled: boolean,
};
@@ -162,7 +154,7 @@
currentState: actionLogger.currentState,
actions: actionLogger.actions,
});
- const result = await this.props.sendReport({
+ const result = await sendReport({
type: reportTypes.ERROR,
platformDetails: {
platform: Platform.OS,
@@ -281,7 +273,6 @@
const preRequestUserState = useSelector(preRequestUserStateSelector);
const dispatchActionPromise = useDispatchActionPromise();
- const callSendReport = useServerCall(sendReport);
const callLogOut = useServerCall(logOut);
const crashReportingEnabled = useIsReportEnabled('crashReports');
return (
@@ -289,7 +280,6 @@
{...props}
preRequestUserState={preRequestUserState}
dispatchActionPromise={dispatchActionPromise}
- sendReport={callSendReport}
logOut={callLogOut}
crashReportingEnabled={crashReportingEnabled}
/>

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 9:41 PM (5 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2612754
Default Alt Text
D9044.diff (5 KB)

Event Timeline