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

Fix bug where record rejected via find stayed in loading state #3043

Merged
merged 1 commit into from
May 5, 2015
Merged

Fix bug where record rejected via find stayed in loading state #3043

merged 1 commit into from
May 5, 2015

Conversation

pangratz
Copy link
Member

@pangratz pangratz commented May 4, 2015

store.getById(typeClass, id) is used inside the rejection handler of
find to get the record and invoke the corresponding hooks. This is
buggy since the record is not loaded yet into the store - a successful
find would mark it as such - and hence the store.getById returned
null. That's why the hooks are not called and the record stays in the
loading state, having the isLoaded flag still being set to false.

The fix is to reuse the record parameter, which is passed to the
find method. By this, the hooks are invoked and the record is passed
transitioned out of the loading state.


This partially addresses #3013

`store.getById(typeClass, id)` is used inside the rejection handler of
`find` to get the record and invoke the corresponding hooks. This is
buggy since the record is not loaded yet into the store - a successful
`find` would mark it as such - and hence the `store.getById` returned
`null`. That's why the hooks are not called and the record stays in the
`loading` state, having the `isLoaded` flag still being set to `false`.

The fix is to reuse the `record` parameter, which is passed to the
`find` method. By this, the hooks are invoked and the record is passed
transitioned out of the `loading` state.
@@ -29,13 +29,11 @@ export function _find(adapter, store, typeClass, id, record) {
return store.push(typeClass, payload);
});
}, function(error) {
var record = store.getById(typeClass, id);
Copy link
Member Author

Choose a reason for hiding this comment

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

This line has been added in 63795a4, where the record parameter was not available. I guess that's the reason why a var record = store.getById(typeClass, id) has been used here; the record parameter is added in 51728a8. So I think reusing the param down below is save...

@igorT
Copy link
Member

igorT commented May 5, 2015

Thanks!

igorT added a commit that referenced this pull request May 5, 2015
…find_request

Fix bug where record rejected via `find` stayed in loading state
@igorT igorT merged commit 3ba1f01 into emberjs:master May 5, 2015
@pangratz pangratz deleted the fix_isLoading_flag_for_failed_find_request branch May 5, 2015 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants