From 125207880dc6942071f100d8df91b9b754d897c8 Mon Sep 17 00:00:00 2001 From: IMB11 Date: Thu, 19 Jun 2025 16:18:00 +0100 Subject: [PATCH] fix: state update race conditons (#3812) --- .../src/components/ui/servers/BackupItem.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/frontend/src/components/ui/servers/BackupItem.vue b/apps/frontend/src/components/ui/servers/BackupItem.vue index 7d1401d7f..de3af15da 100644 --- a/apps/frontend/src/components/ui/servers/BackupItem.vue +++ b/apps/frontend/src/components/ui/servers/BackupItem.vue @@ -16,7 +16,7 @@ import { } from "@modrinth/assets"; import { ButtonStyled, commonMessages, OverflowMenu, ProgressBar } from "@modrinth/ui"; import { defineMessages, useVIntl } from "@vintl/vintl"; -import { ref } from "vue"; +import { ref, computed } from "vue"; import type { Backup } from "@modrinth/utils"; const flags = useFeatureFlags(); @@ -52,9 +52,10 @@ const failedToCreate = computed(() => props.backup.interrupted); const preparedDownloadStates = ["ready", "done"]; const inactiveStates = ["failed", "cancelled"]; -const hasPreparedDownload = computed(() => - preparedDownloadStates.includes(props.backup.task?.file?.state ?? ""), -); +const hasPreparedDownload = computed(() => { + const fileState = props.backup.task?.file?.state ?? ""; + return preparedDownloadStates.includes(fileState); +}); const creating = computed(() => { const task = props.backup.task?.create; @@ -81,6 +82,10 @@ const restoring = computed(() => { const initiatedPrepare = ref(false); const preparingFile = computed(() => { + if (hasPreparedDownload.value) { + return false; + } + const task = props.backup.task?.file; return ( (!task && initiatedPrepare.value) ||