-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 resync remote repos #4113
Fix resync remote repos #4113
Conversation
@@ -282,6 +282,8 @@ function ProjectImportView(instance, config) { | |||
.then(function (data) { | |||
self.get_organizations(); | |||
self.get_accounts(); | |||
// re-sync | |||
self.filter_by(self.filter_by()); |
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.
I'm not sure if this is the proper way of doing this, but I didn't find anything on the docs. But I tested this and works as expected.
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.
Did you test it locally? The line looks fine to me.
Don't we need to re-request the projects also and then apply the filter?
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.
Did you test it locally? The line looks fine to me.
Yes, I tested locally, it works.
Don't we need to re-request the projects also and then apply the filter?
When the filter is set, a new request is made https://github.com/rtfd/readthedocs.org/pull/4113/files#diff-fd74ba503cde92cdf9a406ce7da32f2eL210.
@@ -282,6 +282,8 @@ function ProjectImportView(instance, config) { | |||
.then(function (data) { | |||
self.get_organizations(); | |||
self.get_accounts(); | |||
// re-sync |
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.
It's not a re-sync but a filter by previously selected filter
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.
But this is a hack to trigger the re-sync
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.
yeah, you are right. So, maybe it's better to improve the comment explaining why we are doing this here and how it works behind the scenes.
@@ -282,6 +282,8 @@ function ProjectImportView(instance, config) { | |||
.then(function (data) { | |||
self.get_organizations(); | |||
self.get_accounts(); | |||
// re-sync | |||
self.filter_by(self.filter_by()); |
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.
Did you test it locally? The line looks fine to me.
Don't we need to re-request the projects also and then apply the filter?
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.
I'm not sure about my change, but there is likely a more dedicated mechanism for notifying subscribers of changes or forcing re-evaluation of the observable.
@@ -282,6 +282,9 @@ function ProjectImportView(instance, config) { | |||
.then(function (data) { | |||
self.get_organizations(); | |||
self.get_accounts(); | |||
// This will trigger a new | |||
// request to re-sync the repos | |||
self.filter_by(self.filter_by()); |
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.
I believe the observable should have a notifySubscribers
method that we can call, instead of resetting the variable like this to notify subscribing observables.
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.
I'll try to take a deeper look to the docs and see what I can find.
@@ -282,6 +282,9 @@ function ProjectImportView(instance, config) { | |||
.then(function (data) { | |||
self.get_organizations(); | |||
self.get_accounts(); | |||
// This will trigger a new | |||
// request to re-sync the repos | |||
self.filter_by.valueHasMutated(); |
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.
I took this from https://stackoverflow.com/questions/16261689/force-knockout-to-mark-an-observable-as-changed-even-if-focus-is-still-in-the-f#16261761, still not sure if this is the correct way, but I tested it and works.
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.
This change looks better.
This will need a rebase and regeneration of the static assets. |
Done |
Fix #4101
I'll re-minify the js after see if this is the correct solution p: