From e8790738a45b4c600e044015cf91df30ff28fc4f Mon Sep 17 00:00:00 2001 From: Mohammad Luthfi Fathur Rahman Date: Wed, 2 Nov 2022 14:11:08 +0700 Subject: [PATCH 1/5] Subscribe report event when report successfully created --- src/pages/home/report/ReportActionsView.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index e60546bbcb40c..cae00ecb975b5 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -67,6 +67,7 @@ class ReportActionsView extends React.Component { super(props); this.didLayout = false; + this.didSubscribeToReportTypingEvents = false; this.unsubscribeVisibilityListener = null; @@ -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; @@ -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`. + const didReportSuccessfullyCreated = !this.props.report.pendingFields + || (!this.props.report.pendingFields.addWorkspaceRoom && !this.props.report.pendingFields.createChat); + if (!this.didSubscribeToReportTypingEvents && didReportSuccessfullyCreated) { + Report.subscribeToReportTypingEvents(this.props.report.reportID); + this.didSubscribeToReportTypingEvents = true; + } } componentWillUnmount() { From 75d69f8531823361a1bd3565b8c751e00f9a4d97 Mon Sep 17 00:00:00 2001 From: Luthfi Date: Thu, 3 Nov 2022 10:02:16 +0700 Subject: [PATCH 2/5] Update src/pages/home/report/ReportActionsView.js Co-authored-by: Daniel Gale-Rosen <5487802+dangrous@users.noreply.github.com> --- src/pages/home/report/ReportActionsView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index cae00ecb975b5..42b665fb2a20d 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -238,7 +238,7 @@ class ReportActionsView extends React.Component { // 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`. - const didReportSuccessfullyCreated = !this.props.report.pendingFields + const didCreateReportSuccessfully = !this.props.report.pendingFields || (!this.props.report.pendingFields.addWorkspaceRoom && !this.props.report.pendingFields.createChat); if (!this.didSubscribeToReportTypingEvents && didReportSuccessfullyCreated) { Report.subscribeToReportTypingEvents(this.props.report.reportID); From 57494c086defed8d3a785a71c4a6b9553fbb5100 Mon Sep 17 00:00:00 2001 From: Luthfi Date: Thu, 3 Nov 2022 10:02:28 +0700 Subject: [PATCH 3/5] Update src/pages/home/report/ReportActionsView.js Co-authored-by: Daniel Gale-Rosen <5487802+dangrous@users.noreply.github.com> --- src/pages/home/report/ReportActionsView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 42b665fb2a20d..1f23bf8f74072 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -240,7 +240,7 @@ class ReportActionsView extends React.Component { // The other reports created will have empty field on `pendingFields`. const didCreateReportSuccessfully = !this.props.report.pendingFields || (!this.props.report.pendingFields.addWorkspaceRoom && !this.props.report.pendingFields.createChat); - if (!this.didSubscribeToReportTypingEvents && didReportSuccessfullyCreated) { + if (!this.didSubscribeToReportTypingEvents && didCreateReportSuccessfully) { Report.subscribeToReportTypingEvents(this.props.report.reportID); this.didSubscribeToReportTypingEvents = true; } From d3282613f8c135e3c88b63b756c772741d4e0cff Mon Sep 17 00:00:00 2001 From: Luthfi Date: Thu, 3 Nov 2022 10:02:48 +0700 Subject: [PATCH 4/5] Update src/pages/home/report/ReportActionsView.js Co-authored-by: Daniel Gale-Rosen <5487802+dangrous@users.noreply.github.com> --- src/pages/home/report/ReportActionsView.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 1f23bf8f74072..423210169d4c5 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -235,9 +235,10 @@ class ReportActionsView extends React.Component { 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`. + // 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) { From a35c5ee4e8de2edac638b6a0788033ab796db81b Mon Sep 17 00:00:00 2001 From: Luthfi Date: Thu, 3 Nov 2022 21:07:55 +0700 Subject: [PATCH 5/5] Fix the comment Co-authored-by: Sahil --- src/pages/home/report/ReportActionsView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 423210169d4c5..68ea17082fc4e 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -236,7 +236,7 @@ class ReportActionsView extends React.Component { } // Ensures subscription event succeeds when the report/workspace room is created optimistically. - // Check if the optimistic `OpenReport` or `AddWorkspaceRoom` has succeeded by confirming + // 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