Skip to content

Commit e1709f8

Browse files
committed
Update LayoutCart.vue
1 parent 8fe8e21 commit e1709f8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

components/Layout/LayoutCart.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,32 @@ watch(
121121
},
122122
);
123123
124+
/*
124125
// Use a longer interval if you still want to use an interval
125126
setInterval(() => {
126127
if (cartChanged.value) {
127128
cartChanged.value = false;
128129
debouncedExecute();
129130
}
130-
}, 5000);
131+
}, 5000);*/
132+
133+
if (process.client) {
134+
onMounted(() => {
135+
const intervalId = setInterval(() => {
136+
if (cartChanged.value) {
137+
cartChanged.value = false;
138+
debouncedExecute();
139+
}
140+
}, 5000);
141+
142+
// Clear the interval when the component is unmounted to prevent memory leaks
143+
onBeforeUnmount(() => {
144+
clearInterval(intervalId);
145+
});
146+
});
147+
}
148+
149+
150+
151+
131152
</script>

0 commit comments

Comments
 (0)