Browse Source

refactor: optimize tab reload on tab switch

re #767

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/764/head
Pranav C 3 years ago
parent
commit
6358a4bc39
  1. 10
      packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue
  2. 4
      packages/nc-gui/components/project/table.vue
  3. 2
      packages/nc-gui/components/projectTabs.vue

10
packages/nc-gui/components/project/spreadsheet/rowsXcDataTable.vue

@ -583,6 +583,7 @@ export default {
}, },
mixins: [spreadsheet], mixins: [spreadsheet],
props: { props: {
isActive: Boolean,
tabId: String, tabId: String,
env: String, env: String,
nodes: Object, nodes: Object,
@ -670,6 +671,11 @@ export default {
rowContextMenu: null rowContextMenu: null
}), }),
watch: { watch: {
isActive(n, o) {
if (!o && n) {
this.reload()
}
},
page(p) { page(p) {
this.$store.commit('tabs/MutSetTabState', { this.$store.commit('tabs/MutSetTabState', {
id: this.uniqueId, id: this.uniqueId,
@ -1159,7 +1165,9 @@ export default {
} }
}, },
computed: { computed: {
tabsState() { return this.$store.state.tabs.tabsState || {} }, tabsState() {
return this.$store.state.tabs.tabsState || {}
},
uniqueId() { uniqueId() {
return `${this.tabId}_${this.selectedViewId}` return `${this.tabId}_${this.selectedViewId}`
}, },

4
packages/nc-gui/components/project/table.vue

@ -317,6 +317,7 @@
> >
<rows-xc-data-table <rows-xc-data-table
ref="tabs7" ref="tabs7"
:is-active="isActive"
:tab-id="tabId" :tab-id="tabId"
:show-tabs="relationTabs && relationTabs.length" :show-tabs="relationTabs && relationTabs.length"
:table="nodes.tn" :table="nodes.tn"
@ -384,6 +385,7 @@
<template> <template>
<rows-xc-data-table <rows-xc-data-table
ref="tabs7" ref="tabs7"
:is-active="isActive"
:show-tabs="relationTabs && relationTabs.length" :show-tabs="relationTabs && relationTabs.length"
:table="nodes.tn" :table="nodes.tn"
:nodes="nodes" :nodes="nodes"
@ -639,7 +641,7 @@ export default {
head() { head() {
return {} return {}
}, },
props: ['nodes', 'hideLogWindows', 'tabId'] props: ['nodes', 'hideLogWindows', 'tabId', 'isActive']
} }
</script> </script>

2
packages/nc-gui/components/projectTabs.vue

@ -61,8 +61,8 @@
> >
<!-- <sqlLogAndOutput :hide="hideLogWindows">--> <!-- <sqlLogAndOutput :hide="hideLogWindows">-->
<TableView <TableView
v-if="activeTab === `${(tab._nodes && tab._nodes).type || ''}||${(tab._nodes && tab._nodes.dbAlias) || ''}||${tab.name}`"
:ref="'tabs'+index" :ref="'tabs'+index"
:is-active="activeTab === `${(tab._nodes && tab._nodes).type || ''}||${(tab._nodes && tab._nodes.dbAlias) || ''}||${tab.name}`"
:tab-id="`${pid}||${(tab._nodes && tab._nodes).type || ''}||${(tab._nodes && tab._nodes.dbAlias) || ''}||${tab.name}`" :tab-id="`${pid}||${(tab._nodes && tab._nodes).type || ''}||${(tab._nodes && tab._nodes.dbAlias) || ''}||${tab.name}`"
:hide-log-windows.sync="hideLogWindows" :hide-log-windows.sync="hideLogWindows"
:nodes="tab._nodes" :nodes="tab._nodes"

Loading…
Cancel
Save