fix: Fixed IHI tab icon duplication bug

This commit is contained in:
Joel Collins 2020-11-24 12:25:30 +00:00
parent 755ee6629f
commit e17366d976

View file

@ -17,7 +17,7 @@
class="uk-flex uk-flex-column uk-padding-remove uk-width-auto uk-height-1-1 uk-text-center" class="uk-flex uk-flex-column uk-padding-remove uk-width-auto uk-height-1-1 uk-text-center"
> >
<!-- For each top tab --> <!-- For each top tab -->
<template v-for="(item, index) in enabledTopTabs"> <template v-for="(item, index) in topTabs">
<!-- Render the tab icon --> <!-- Render the tab icon -->
<tabIcon <tabIcon
:id="item.id + '-tab-icon'" :id="item.id + '-tab-icon'"
@ -34,8 +34,6 @@
<hr v-if="item.divide" :key="'tab-divider-' + index" /> <hr v-if="item.divide" :key="'tab-divider-' + index" />
</template> </template>
<hr id="extension-tab-divider" />
<!-- For each plugin tab --> <!-- For each plugin tab -->
<tabIcon <tabIcon
v-for="plugin in pluginsGuiList" v-for="plugin in pluginsGuiList"
@ -79,7 +77,7 @@
> >
<!-- For each top tab --> <!-- For each top tab -->
<tabContent <tabContent
v-for="item in enabledTopTabs" v-for="item in topTabs"
:id="item.id + '-tab-content'" :id="item.id + '-tab-content'"
:key="item.id + '-tab-content'" :key="item.id + '-tab-content'"
:tab-i-d="item.id" :tab-i-d="item.id"
@ -212,18 +210,6 @@ export default {
}, },
computed: { computed: {
enabledTopTabs: function() {
var enabledTabs = this.topTabs;
if (this.$store.state.IHIEnabled) {
enabledTabs.push({
id: "slidescan",
icon: "settings_overscan",
component: slideScanContent
});
}
return enabledTabs;
},
pluginsUri: function() { pluginsUri: function() {
return `${this.$store.getters.baseUri}/api/v2/extensions`; return `${this.$store.getters.baseUri}/api/v2/extensions`;
}, },
@ -241,7 +227,7 @@ export default {
tabOrder: function() { tabOrder: function() {
var ind = []; var ind = [];
for (const tab of this.enabledTopTabs) { for (const tab of this.topTabs) {
ind.push(tab.id); ind.push(tab.id);
} }
for (const plugin of this.pluginsGuiList) { for (const plugin of this.pluginsGuiList) {
@ -270,12 +256,24 @@ export default {
this.$store.commit("changeAutoGpuPreview", true); this.$store.commit("changeAutoGpuPreview", true);
this.$store.commit("changeTrackWindow", true); this.$store.commit("changeTrackWindow", true);
} }
// Update top tabs
this.updateTopTabs(this.$store.state.IHIEnabled);
// Update plugins // Update plugins
this.updatePlugins().then(() => { this.updatePlugins().then(() => {
// Start initialisation modals // Start initialisation modals
this.startModals(); this.startModals();
}); });
} }
// Watch for host 'ready', then update status
this.unwatchStoreFunction = this.$store.watch(
state => {
return state.IHIEnabled;
},
IHIEnabled => {
this.updateTopTabs(IHIEnabled);
}
);
}, },
mounted() { mounted() {
@ -302,6 +300,19 @@ export default {
}, },
methods: { methods: {
updateTopTabs: function(IHIEnabled) {
if (IHIEnabled) {
this.topTabs.push({
id: "slidescan",
icon: "settings_overscan",
component: slideScanContent,
divide: true
});
} else {
// If the connection is now disconnected, empty capture list
this.topTabs = this.topTabs.filter(tab => tab.id != "slidescan");
}
},
updatePlugins: function() { updatePlugins: function() {
return axios return axios
.get(this.pluginsUri) .get(this.pluginsUri)