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 1 commit
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
12 changes: 11 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,16 @@ class ReportActionsView extends React.Component {
if (didManuallyMarkReportAsUnread) {
this.setState({newMarkerSequenceNumber: this.props.report.lastReadSequenceNumber + 1});
}

// Preventing the subscribe event fail when the creating the report/workspace room optimistically. Check if the optimistic
// `OpenReport` or `AddWorkspaceRoom` success by `pendingFields.createChat` or `pendingFields.addWorkspaceRoom` is set to null.
// The other reports created will have empty field on `pendingFields`.
mollfpr marked this conversation as resolved.
Show resolved Hide resolved
const didReportSuccessfullyCreated = !this.props.report.pendingFields
mollfpr marked this conversation as resolved.
Show resolved Hide resolved
|| (!this.props.report.pendingFields.addWorkspaceRoom && !this.props.report.pendingFields.createChat);
if (!this.didSubscribeToReportTypingEvents && didReportSuccessfullyCreated) {
mollfpr marked this conversation as resolved.
Show resolved Hide resolved
Report.subscribeToReportTypingEvents(this.props.report.reportID);
this.didSubscribeToReportTypingEvents = true;
}
}

componentWillUnmount() {
Expand Down