Skip to content

Commit 9f42733

Browse files
author
Guillaume Chau
committed
feat: auto refresh if no components
1 parent a10a424 commit 9f42733

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/app-frontend/src/App.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
</template>
166166

167167
<script>
168-
import { mapState } from 'vuex'
168+
import { mapState, mapGetters } from 'vuex'
169169
import { SPECIAL_TOKENS } from '@utils/util'
170170
import Keyboard from '@front/mixins/keyboard'
171171
import GroupDropdown from '@front/components/GroupDropdown.vue'
@@ -238,6 +238,10 @@ export default {
238238
view: state => state.view
239239
}),
240240
241+
...mapGetters('components', {
242+
totalComponentCount: 'totalCount'
243+
}),
244+
241245
specialTokens () {
242246
return SPECIAL_TOKENS
243247
},
@@ -274,10 +278,12 @@ export default {
274278
this.mediaQuery = window.matchMedia('(min-width: 685px)')
275279
this.switchView(this.mediaQuery)
276280
this.mediaQuery.addListener(this.switchView)
281+
this.autoRefreshTimer = setInterval(this.shouldAutoRefresh, 1000)
277282
},
278283
279284
destroyed () {
280285
this.mediaQuery.removeListener(this.switchView)
286+
clearInterval(this.autoRefreshTimer)
281287
},
282288
283289
methods: {
@@ -291,6 +297,12 @@ export default {
291297
})
292298
},
293299
300+
shouldAutoRefresh () {
301+
if (this.totalComponentCount === 0) {
302+
this.refresh()
303+
}
304+
},
305+
294306
switchView (mediaQueryEvent) {
295307
this.$store.commit(
296308
'SWITCH_VIEW',

0 commit comments

Comments
 (0)