Guard MyWashStart timers after teardown

This commit is contained in:
Jeppe Bundgaard
2026-07-06 15:02:57 +02:00
parent d84e9e3406
commit 5a5cc0bed3
@@ -715,6 +715,7 @@ const activeWashRestoreTimeout = ref<ReturnType<typeof window.setTimeout> | null
const recentCompletedRefreshTimeout = ref<ReturnType<typeof window.setTimeout> | null>(null);
const recentCompletedRefreshInterval = ref<ReturnType<typeof window.setInterval> | null>(null);
const isMyWashStartUnmounted = ref(false);
const getMyWashWindow = () => (typeof window === "undefined" ? null : window);
const registrationOptions = computed(() =>
customerVehicles.value
@@ -1327,14 +1328,14 @@ refreshRecentlyCompletedWashState();
const clearRecentCompletedRefreshTimeout = () => {
if (recentCompletedRefreshTimeout.value !== null) {
window.clearTimeout(recentCompletedRefreshTimeout.value);
getMyWashWindow()?.clearTimeout(recentCompletedRefreshTimeout.value);
recentCompletedRefreshTimeout.value = null;
}
};
const clearRecentCompletedRefreshInterval = () => {
if (recentCompletedRefreshInterval.value !== null) {
window.clearInterval(recentCompletedRefreshInterval.value);
getMyWashWindow()?.clearInterval(recentCompletedRefreshInterval.value);
recentCompletedRefreshInterval.value = null;
}
};
@@ -1350,7 +1351,12 @@ const scheduleRecentCompletedWashRefresh = (attempt = 0) => {
return;
}
recentCompletedRefreshTimeout.value = window.setTimeout(() => {
const hostWindow = getMyWashWindow();
if (!hostWindow) {
return;
}
recentCompletedRefreshTimeout.value = hostWindow.setTimeout(() => {
if (isMyWashStartUnmounted.value) {
return;
}
@@ -1362,7 +1368,12 @@ const scheduleRecentCompletedWashRefresh = (attempt = 0) => {
const startRecentCompletedWashRefresh = () => {
clearRecentCompletedRefreshInterval();
recentCompletedRefreshInterval.value = window.setInterval(() => {
const hostWindow = getMyWashWindow();
if (!hostWindow) {
return;
}
recentCompletedRefreshInterval.value = hostWindow.setInterval(() => {
if (isMyWashStartUnmounted.value) {
clearRecentCompletedRefreshInterval();
return;