Start sync with POST and show progress when a sync is running

Closes #1
This commit is contained in:
Sansan committed 2026-10-06 18:57:02 +02:00
1 parent f972b579fc
commit 2e7be01487
1 file changed
+9 -18
+9 -18
View File
@@ -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);
});
});