-
Notifications
You must be signed in to change notification settings - Fork 943
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
Availability improvements #901
Conversation
In case max bookable day count exceeds 90 days, fetch a second batch of time slots.
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.
Check comment. I guess another option would've been to request timeslots as needed, e.g. when the user changes the calendar month. But I guess fetching all timeslots is ok as well.
dispatch(timeSlotsRequest(secondParams)).then(secondBatch => { | ||
const combined = timeSlots.concat(secondBatch); | ||
dispatch(fetchTimeSlotsSuccess(combined)); | ||
}); |
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.
Should there be a return
before the dispatch
or a .catch
on the promise to handle error in the request?
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.
The .catch
is left out so that in case of an error the .catch
of the outer promise handles it. This way there error action is fired in case either of the time slot requests fail. A succeed action is dispatched when both requests succeed.
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.
How would a return
help with handling a failing request here?
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.
The failing promise never goes to the outer .catch
without the return
.
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.
Well so it seems. I was sure I had this tested. Well spotted 👍, I'll add the return
.
7b254de
to
0414d2a
Compare
Added the missing |
Return the nested promise so that errors from it will be caucht in the catch block of the outer promise.
Fixes two problems with availability: