From f8295afc310d424bbb8cf0d78879596e8dc1ff15 Mon Sep 17 00:00:00 2001 From: vikingowl Date: Wed, 24 Jan 2024 15:17:55 +0100 Subject: [PATCH] added variable for the update-interval --- frontend/src/components/CurrentlyBuilding.vue | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/CurrentlyBuilding.vue b/frontend/src/components/CurrentlyBuilding.vue index 007a08e..bb15da9 100644 --- a/frontend/src/components/CurrentlyBuilding.vue +++ b/frontend/src/components/CurrentlyBuilding.vue @@ -71,6 +71,9 @@ import { onMounted, ref } from 'vue' import type { Packages } from '@/types/Packages' import { Package } from '@/types/Package' +// This variable sets the update-interval +const updateIntervalInMinutes = 5 + const lastUpdatedTime = ref(0) const lastUpdatedSeconds = ref(0) const rtf = new Intl.RelativeTimeFormat('en', { @@ -174,14 +177,17 @@ onMounted(() => { lastUpdatedSeconds.value = Math.floor((Date.now() - lastUpdatedTime.value) / 1000) }, 1000) - const interval = setInterval(() => { - getTotalPackages() - getBuiltPackages() - getBuildingPackages() - getQueuedPackages() - lastUpdatedTime.value = Date.now() - lastUpdatedSeconds.value = Math.floor((Date.now() - lastUpdatedTime.value) / 1000) - }, 120_000) + const interval = setInterval( + () => { + getTotalPackages() + getBuiltPackages() + getBuildingPackages() + getQueuedPackages() + lastUpdatedTime.value = Date.now() + lastUpdatedSeconds.value = Math.floor((Date.now() - lastUpdatedTime.value) / 1000) + }, + updateIntervalInMinutes * 60 * 1000 + ) })