Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe report event when report successfully created #12365

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ReportActionsView extends React.Component {
super(props);

this.didLayout = false;
this.didSubscribeToReportTypingEvents = false;

this.unsubscribeVisibilityListener = null;

Expand Down Expand Up @@ -100,7 +101,6 @@ class ReportActionsView extends React.Component {
this.setState({newMarkerSequenceNumber: 0});
});

Report.subscribeToReportTypingEvents(this.props.report.reportID);
this.keyboardEvent = Keyboard.addListener('keyboardDidShow', () => {
if (!ReportActionComposeFocusManager.isFocused()) {
return;
Expand Down Expand Up @@ -234,6 +234,17 @@ class ReportActionsView extends React.Component {
if (didManuallyMarkReportAsUnread) {
this.setState({newMarkerSequenceNumber: this.props.report.lastReadSequenceNumber + 1});
}

// Ensures subscription event succeeds when the report/workspace room is created optimistically.
// Check if the optimistic `OpenReport` or `AddWorkspaceRoom` has succeeded by confirming
// any `pendingFields.createChat` or `pendingFields.addWorkspaceRoom` fields are set to null.
// Existing reports created will have empty fields for `pendingFields`.
const didCreateReportSuccessfully = !this.props.report.pendingFields
|| (!this.props.report.pendingFields.addWorkspaceRoom && !this.props.report.pendingFields.createChat);
if (!this.didSubscribeToReportTypingEvents && didCreateReportSuccessfully) {
Report.subscribeToReportTypingEvents(this.props.report.reportID);
this.didSubscribeToReportTypingEvents = true;
}
}

componentWillUnmount() {
Expand Down