Fdans has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/397995 )
Change subject: Fix infinite loop
......................................................................
Fix infinite loop
For the future, the flow of events and data in WikiSelector is too
circular. The init calls get triggered when they're not necessary,
after state changes.
Also, the way the hidden div is added with an id is not great, that
should at least have a class and in general should be added relative to
the component in case multiple versions of the same component are used
on the page.
Bug: T182700
Change-Id: I1dd5f4bce62caaf14215b4fa158d030f53e8f084
---
M src/components/WikiSelector.vue
1 file changed, 18 insertions(+), 9 deletions(-)
Approvals:
jenkins-bot: Verified
Fdans: Verified; Looks good to me, approved
diff --git a/src/components/WikiSelector.vue b/src/components/WikiSelector.vue
index c317788..bf8c50d 100644
--- a/src/components/WikiSelector.vue
+++ b/src/components/WikiSelector.vue
@@ -31,6 +31,8 @@
</template>
<script>
+import Vue from 'vue';
+
import sitematrix from '../apis/sitematrix';
import SearchResults from './widgets/SearchResults';
import _ from '../lodash-custom-bundle';
@@ -114,26 +116,33 @@
methods: {
initWithCurrentProject () {
const siteProject = this.$store.state.project;
- if (siteProject === "") return;
+ if (siteProject === '') { return; }
+
sitematrix.getByProjectFamily().then(byFamily => {
this.byFamily = byFamily;
this.family = byFamily.find((family) => {
this.project = family.projects.find((project) => {
- return project.code === siteProject
+ return project.code === siteProject;
});
- this.close();
return this.project;
- })
- this.searchDisplay = this.family.title + ' - ' +
this.project.title;
- this.mode = modes.project;
- this.searchData = this.family.projects;
+ });
+ if (this.family && this.project) {
+ this.searchDisplay = this.family.title + ' - ' +
this.project.title;
+ this.mode = modes.project;
+ this.searchData = this.family.projects;
+ } else {
+ this.searchDisplay = 'CLOSED: ' + (siteProject);
+ this.mode = modes.family;
+ this.searchData = byFamily;
+ }
+ Vue.nextTick(() => this.close());
});
},
initTextWidthMeasurer () {
- if (!$("#wikiselector-hidden-measurer").length) {
+ if (!$('#wikiselector-hidden-measurer').length) {
let div = document.createElement('div');
- div.setAttribute("id", "wikiselector-hidden-measurer");
+ div.setAttribute('id', 'wikiselector-hidden-measurer');
document.body.appendChild(div);
}
},
--
To view, visit https://gerrit.wikimedia.org/r/397995
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1dd5f4bce62caaf14215b4fa158d030f53e8f084
Gerrit-PatchSet: 1
Gerrit-Project: analytics/wikistats2
Gerrit-Branch: master
Gerrit-Owner: Milimetric <[email protected]>
Gerrit-Reviewer: Fdans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits