-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Show a growl and redirect when navigating to a chat we can't access #4018
Show a growl and redirect when navigating to a chat we can't access #4018
Conversation
Modified the original proposal to match your comment more closely @marcaaron. I'm using I think that happens because the report was still saved under |
Updated to use the new |
@rdjuric Ok that sounds like a good solution to me, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments. Nice work so far 🎉
src/libs/actions/Report.js
Outdated
|
||
// If we receive a 404 response while fetching a single report, treat that report as inacessible. | ||
if (jsonCode === 404 && chatList.length === 1) { | ||
throw new Error('inacessible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we perhaps create a constant for this and maybe give it a slightly more descriptive error something like this?
const CONST = {
...,
ERROR: {
INACCESSIBLE_REPORT: 'Report not found',
},
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we can use CONST.ERROR.INACCESSIBLE_REPORT
in these two locations.
src/libs/actions/Report.js
Outdated
}) | ||
.catch((err) => { | ||
if (err.message === 'inacessible' && shouldRedirectIfInacessible) { | ||
Log.info('[Report] Report data is inacessible.', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maybe get rid of this log since it will actually print to the server and we don't need it to do that in this case.
Thanks for the feedback! Updated @marcaaron. |
Can we merge this one @marcaaron? |
src/libs/actions/Report.js
Outdated
Log.info('[Report] successfully fetched report data', true); | ||
fetchedReports = reportSummaryList; | ||
|
||
// If we receive a 404 response while fetching a single report, treat that report as inacessible. | ||
if (jsonCode === 404 && chatList.length === 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- not sure checking the
chatList
is necessary on second thought - we should be checking
shouldRedirectIfInacessible
when we throw this error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. If we're controlling the redirect via the shouldRedirectIfInacessible
param, checking the chatList
is a weird restriction.
src/libs/actions/Report.js
Outdated
* | ||
* Fetches chat reports when provided a list of chat report IDs. | ||
* If the shouldRedirectIfInacessible flag is set, we redirect to the Concierge chat | ||
* when fetching a single chat that is inacessible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* when fetching a single chat that is inacessible. | |
* when we find an inaccessible chat. |
src/libs/actions/Report.js
Outdated
@@ -368,6 +375,13 @@ function fetchChatReportsByIDs(chatList) { | |||
PersonalDetails.getFromReportParticipants(Object.values(simplifiedReports)); | |||
|
|||
return _.map(fetchedReports, report => report.reportID); | |||
}) | |||
.catch((err) => { | |||
if (err.message === CONST.REPORT.ERROR.INACCESSIBLE_REPORT && shouldRedirectIfInacessible) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (err.message === CONST.REPORT.ERROR.INACCESSIBLE_REPORT && shouldRedirectIfInacessible) { | |
if (err.message === CONST.REPORT.ERROR.INACCESSIBLE_REPORT) { |
src/libs/actions/Report.js
Outdated
Log.info('[Report] successfully fetched report data', true); | ||
fetchedReports = reportSummaryList; | ||
|
||
// If we receive a 404 response while fetching a single report, treat that report as inacessible. | ||
if (jsonCode === 404 && chatList.length === 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (jsonCode === 404 && chatList.length === 1) { | |
if (jsonCode === 404 && shouldRedirectIfInacessible) { |
@@ -107,6 +108,9 @@ class ReportActionsView extends React.Component { | |||
|
|||
componentDidMount() { | |||
AppState.addEventListener('change', this.onVisibilityChange); | |||
if (!this.props.report.reportID) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like there's a special significance to this not existing. Can we add a comment above to maybe explain why this does not exist and why it's being called with this parameter? Maybe something like
If the reportID is not found then we have either not loaded this chat or the user is unable to access it. We will attempt to fetch it and redirect if still not accessible.
Updates made @marcaaron |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Nice ! Thanks @rdjuric |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging in version: 1.0.79-5🚀
|
🚀 Deployed to production in version: 1.0.80-2🚀
|
Details
Modifies our
fetchChatReportsByIDs
action to receive a boolean flagshouldRedirectIfInacessible
. With this flag set to true, the action will redirect to Concierge and display a Growl if it was asked to fetch a single report and that report was inacessible.We call a report inacessible if our API answers with a
jsonCode
of404
when we try to fetch it.In our
ReportActionsView
, check if the current report has a reportID saved locally. If it doesn't, try to fetch the report with theshouldRedirectIfInacessible
flag set to true.Fixed Issues
$ #3810
Tests
QA Steps
Tested On
Screenshots
Web
web.mov
Mobile Web
mWeb.mp4
Desktop
iOS
Android