Start sync with POST and show progress when a sync is running
Closes #1
This commit is contained in:
1 parent
f972b579fc
commit
2e7be01487
1 file changed
+8
-17
@@ -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;
|
||||
await this.APIsyncSoundtracks();
|
||||
} catch (error) {
|
||||
// 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.showSyncModal = true;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
},
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user