Skip to content

Commit 4683a7f

Browse files
author
Guillaume Chau
committed
fix(ui): prevent loading client addons multiple times
1 parent 93765c9 commit 4683a7f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/@vue/cli-ui/src/components/ClientAddonLoader.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,30 @@ export default {
88
query: CLIENT_ADDONS,
99
fetchPolicy: 'no-cache',
1010
manual: true,
11-
result ({ data: { clientAddons } }) {
12-
clientAddons.forEach(this.loadAddon)
11+
result ({ data: { clientAddons }, stale }) {
12+
if (!stale) {
13+
clientAddons.forEach(this.loadAddon)
14+
this.$_lastRead = Date.now()
15+
}
1316
}
1417
},
1518
1619
$subscribe: {
1720
clientAddonAdded: {
1821
query: CLIENT_ADDON_ADDED,
1922
result ({ data }) {
20-
this.loadAddon(data.clientAddonAdded)
23+
if (this.$_lastRead && Date.now() - this.$_lastRead > 1000) {
24+
this.loadAddon(data.clientAddonAdded)
25+
}
2126
}
2227
}
2328
}
2429
},
2530
31+
created () {
32+
this.$_lastRead = null
33+
},
34+
2635
methods: {
2736
loadAddon (addon) {
2837
// eslint-disable-next-line no-console

0 commit comments

Comments
 (0)