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(issue): Make sure the right repository is fetched #332

Merged
merged 2 commits into from Sep 29, 2017

Conversation

chinesedfan
Copy link
Member

Fixed #315 and #318.

In fact, #318 is fixed partially by #317, as getContributorsByDispatch is not called correctly. But the main problem is that the right repository is not always fetched.

If visit issue.screen from:

So I use props.issue.repository_url to check, which belongs to the fetched issue.

@@ -160,10 +159,11 @@ class Issue extends Component {
issueURLParam ? issueCommentsURL : issueParam.comments_url
),
]).then(() => {
const issue = this.props.issue;
Copy link
Member

Choose a reason for hiding this comment

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

@chinesedfan can as earlier receive variable issue (144 line)? Then you just do not need this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lex111 No, we should read after those 2 promises, getIssueFromUrlByDispatch and getIssueCommentsByDispatch, are fulfilled. Or this.props.issue may refer to the previous wrong issue.

That's what I mean "the fetched issue". Sorry for my poor English pr description.

Copy link
Member

Choose a reason for hiding this comment

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

Nope that shouldn't be the case :)

In the top of the file, we're mapping parts of our state object into our props. So issue isn't a fixed object parameter here, but will always reflect what's happening with state. If getIssueFromUrlByDispatch and/or getIssueCommentsByDispatch update state.issue where state is our Redux container - our issue props will always reflect this. So we should be good with leaving it as part of the destructuring in line 144 😃

Please let me know to clarify this if it's still not making any sense to you mate

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. this.props.issue will always be updated by redux, but in line 144, issue is just a temporary local variable destructed from this.props, which will never be updated.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I'm sorry, you're right here. It gets modified in the promise call and our current local variable isn't really going to reflect this.

Cheers thank you mate, and I'm sorry for causing any confusion 😞

Copy link
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

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

Thanks a million for this and appreciate you catching exactly what was causing the error @chinesedfan 🎉

Left one comment per @lex111's suggestion, otherwise this is solid :)

@@ -160,10 +159,11 @@ class Issue extends Component {
issueURLParam ? issueCommentsURL : issueParam.comments_url
),
]).then(() => {
const issue = this.props.issue;
Copy link
Member

Choose a reason for hiding this comment

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

Nope that shouldn't be the case :)

In the top of the file, we're mapping parts of our state object into our props. So issue isn't a fixed object parameter here, but will always reflect what's happening with state. If getIssueFromUrlByDispatch and/or getIssueCommentsByDispatch update state.issue where state is our Redux container - our issue props will always reflect this. So we should be good with leaving it as part of the destructuring in line 144 😃

Please let me know to clarify this if it's still not making any sense to you mate

repository.full_name !==
issueParam.repository_url.replace(`${apiRoot}/repos/`, '')
Copy link
Member

Choose a reason for hiding this comment

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

So this was the culprit. It looks like issueParam, unlike props.issue, is actually obtained from the navigation.params so it's not being updated when those calls within Promise.all are fired

Copy link
Member Author

Choose a reason for hiding this comment

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

Suppose we have visited repository A, and try to visit another issue/pr of repository B. props.repository will refer to A at first. issueParam.repository_url will refer to B.

The basic logic is correct here. But issueParam.repository_url does not always have value, which may be caused by issueParam itself or issueParam.repository_url as my PR description says.

Copy link
Member Author

Choose a reason for hiding this comment

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

@housseindjirdeh Any feedbacks? :)

Copy link
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

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

Thank you so much @chinesedfan, and apologies for not getting to this sooner!

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.

Wrong issue/pr permissions when visit from notifications tab
5 participants