From 2e7be014870144ddbbef9403d56b1c70eb6e5598 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 6 Oct 2026 18:57:02 +0200 Subject: [PATCH] Start sync with POST and show progress when a sync is running Closes #1 --- src/components/items/extraButtons.vue | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/components/items/extraButtons.vue b/src/components/items/extraButtons.vue index 7812a75..330814c 100644 --- a/src/components/items/extraButtons.vue +++ b/src/components/items/extraButtons.vue @@ -46,25 +46,17 @@ export default { }, async startSync() { try { - // Start the sync - const response = await this.APIsyncSoundtracks(); - // Check if sync was actually started or if one is in progress - if (response && (response.status === 423 || (response.data && response.data.includes("in progress")))) { - // Sync is already in progress - show modal with polling - this.syncInProgress = true; - } else { - this.syncInProgress = true; - } - // Show the modal which will poll for progress - this.showSyncModal = true; + await this.APIsyncSoundtracks(); } catch (error) { - console.error("Failed to start sync:", error); - // If error is 423, sync is already in progress - if (error.response && error.response.status === 423) { - this.syncInProgress = true; - this.showSyncModal = true; + // 423 means a sync is already running: show its progress + if (!error.response || error.response.status !== 423) { + console.error("Failed to start sync:", error); + return; } } + // Show the modal which will poll for progress + this.syncInProgress = true; + this.showSyncModal = true; }, handleSyncButtonClick() { // If we have a completed sync result, just show it @@ -119,14 +111,13 @@ export default { APIsyncSoundtracks() { return new Promise((resolve, reject) => { this.axios({ - method: "get", + method: "post", url: `${window.__RUNTIME_CONFIG__.API_HOSTNAME}/sync`, }) .then((response) => { resolve(response); }) .catch(function(error) { - console.log(error); reject(error); }); });