From f93af05c28977011ebf12f1478c0d8d6c667f554 Mon Sep 17 00:00:00 2001
From: Konrad Mohrfeldt <km@roko.li>
Date: Wed, 29 Jan 2025 15:09:38 +0100
Subject: [PATCH] fix: avoid not-found redirect for timeslot episode editor
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We need to wait for the timeslot to be updated before routing to the
editor page, because otherwise the editor page might redirect back to
the overview because it can’t find the episode for the timeslot.
---
 src/components/shows/TimeSlotRow.vue | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/components/shows/TimeSlotRow.vue b/src/components/shows/TimeSlotRow.vue
index 49acab7..d7069ca 100644
--- a/src/components/shows/TimeSlotRow.vue
+++ b/src/components/shows/TimeSlotRow.vue
@@ -161,7 +161,8 @@ const hasEnded = computed(() => now.value > end.value)
 const { create: createEpisode, isSaving: isCreatingEpisode } = useCreateBehaviour(
   async function () {
     const episode = await episodeStore.create({ showId: props.timeslot.showId })
-    episodeId.value = episode.id
+    // We don’t set episodeId.value here, because we need to know when the change has been persisted.
+    await timeslotStore.partialUpdate(props.timeslot.id, { episodeId: episode.id })
     await router.push({
       name: 'show-timeslot-details',
       params: { timeslotId: props.timeslot.id },
-- 
GitLab