-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from 9 commits
49b293c
fd089ab
650aa1f
2a365ab
2611403
80530b9
7fb9038
e5d2979
85749e3
e7f9d50
0ed5ef4
563393e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -298,19 +298,26 @@ function fetchIOUReportID(debtorEmail) { | |||||
} | ||||||
|
||||||
/** | ||||||
* Fetches chat reports when provided a list of | ||||||
* chat report IDs | ||||||
* | ||||||
* 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. | ||||||
* @param {Array} chatList | ||||||
* @param {Boolean} shouldRedirectIfInacessible | ||||||
* @returns {Promise<Number[]>} only used internally when fetchAllReports() is called | ||||||
*/ | ||||||
function fetchChatReportsByIDs(chatList) { | ||||||
function fetchChatReportsByIDs(chatList, shouldRedirectIfInacessible = false) { | ||||||
let fetchedReports; | ||||||
const simplifiedReports = {}; | ||||||
return API.GetReportSummaryList({reportIDList: chatList.join(',')}) | ||||||
.then(({reportSummaryList}) => { | ||||||
.then(({reportSummaryList, jsonCode}) => { | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. If we're controlling the redirect via the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
throw new Error('inacessible'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Then we can use |
||||||
} | ||||||
|
||||||
return Promise.all(_.map(fetchedReports, (chatReport) => { | ||||||
// If there aren't any IOU actions, we don't need to fetch any additional data | ||||||
if (!chatReport.hasIOUAction) { | ||||||
|
@@ -368,6 +375,14 @@ function fetchChatReportsByIDs(chatList) { | |||||
PersonalDetails.getFromReportParticipants(Object.values(simplifiedReports)); | ||||||
|
||||||
return _.map(fetchedReports, report => report.reportID); | ||||||
}) | ||||||
.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 commentThe 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. |
||||||
Growl.error(translateLocal('notFound.chatYouLookingForCannotBeFound')); | ||||||
// eslint-disable-next-line no-use-before-define | ||||||
navigateToConciergeChat(); | ||||||
} | ||||||
}); | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import {withOnyx} from 'react-native-onyx'; | |
import Text from '../../../components/Text'; | ||
import { | ||
fetchActions, | ||
fetchChatReportsByIDs, | ||
updateLastReadActionID, | ||
setNewMarkerPosition, | ||
subscribeToReportTypingEvents, | ||
|
@@ -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 commentThe 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
|
||
fetchChatReportsByIDs([this.props.reportID], true); | ||
} | ||
subscribeToReportTypingEvents(this.props.reportID); | ||
this.keyboardEvent = Keyboard.addListener('keyboardDidShow', () => { | ||
if (ReportActionComposeFocusManager.isFocused()) { | ||
|
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.