Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Ensure camelcaseKeys is never passed a non-object #1049

Merged
merged 1 commit into from
Nov 30, 2018

Conversation

nabeel-
Copy link
Contributor

@nabeel- nabeel- commented Nov 11, 2018

Ensure camelcaseKeys is never passed a non-object

Currently, the /api/v3/juzs endpoint is 500ing, which causes camelcaseKeys to be called with undefined. According to sindresorhus/camelcase-keys#15, we should ensure we never call camelcaseKeys with something other than an object. Ideally, this is fixed on the BE where we fix the issue that is causing the BE to 500 but this will at least ensure the FE does not completely break and hang.

I suspect this is also the reason why the homepage of the staging site is hanging (http://staging.quran.com/).

Checklist

  • Unit tests written
  • Manually tested
  • Prettier & ESLint were run
  • New dependencies are included in package-lock.json

@ahmedre
Copy link
Contributor

ahmedre commented Nov 11, 2018

Deployed to: http://staging.quran.com:32780

@imranariffin
Copy link

imranariffin commented Nov 17, 2018

@nabeel- I'm very new to the project but I think it would be great if you can add a simple test for each of the reducers.

@@ -52,7 +52,9 @@ export default (state = INITIAL_STATE, action: $TsFixMe) => {
case FETCH_AUDIOPLAYER: {
return handle(state, action, {
success: prevState => {
const audioFile: $TsFixMe = camelcaseKeys(action.payload.audio_file);
const audioFile: $TsFixMe = camelcaseKeys(
action.payload.audio_file || {}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is awesome! perhaps we should use lodash/get? so get(action, 'payload.audio_file', {}) such that if payload is null, this would still work

@mmahalwy mmahalwy merged commit 60aef11 into quran:master Nov 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants