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

Catch Notifications Errors on Details Pages #197

Merged
merged 3 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a
setChannels(availableChannels);
return availableChannels;
})
.catch((error: any) => {
console.log('error when retrieving notification configs:', error);
})
.then((availableChannels: any) => {
httpClient
.get(`../api/reporting/reportDefinitions/${reportDefinitionId}`)
Comment on lines +500 to 505
Copy link
Member

@joshuali925 joshuali925 Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can flatten this chain and reuse the catch inside your nested .then. Otherwise this http call will still happen even if availableChannels is undefined

Suggested change
.catch((error: any) => {
console.log('error when retrieving notification configs:', error);
})
.then((availableChannels: any) => {
httpClient
.get(`../api/reporting/reportDefinitions/${reportDefinitionId}`)
.then((availableChannels: any) => ({
availableChannels,
response: httpClient.get(`../api/reporting/reportDefinitions/${reportDefinitionId}`)
}))
.then(({availableChannels, response}) => {

Edit: fixed a bit, still untested just a suggestion to avoid unnecessary http call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. The nested http call needs to happen regardless of whether or not availableChannels is defined.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl
let availableChannels = getAvailableNotificationsChannels(response.config_list);
return availableChannels;
})
.catch((error: any) => {
console.log('error when retrieving notification configs:', error);
})
.then((availableChannels: any) => {
httpClient
.get('../api/reporting/reports/' + reportId)
Expand Down