Add Komoot activity import with guided browser-based batch flow #25

Open
McPringle wants to merge 23 commits from McPringle/komoot-import into main
Showing only changes of commit 0a98aa523d - Show all commits

View file

@ -441,6 +441,7 @@
let importedCount = 0; let importedCount = 0;
let failedCount = 0; let failedCount = 0;
let cancelled = false; let cancelled = false;
let rateLimited = false;
const totalActivitiesToImport = activitiesToImport.length; const totalActivitiesToImport = activitiesToImport.length;
for (const [index, activity] of activitiesToImport.entries()) { for (const [index, activity] of activitiesToImport.entries()) {
@ -455,6 +456,15 @@
body: buildImportPayload(activity.id) body: buildImportPayload(activity.id)
}); });
if (response.status === 429) {
rateLimited = true;
activity.uiImportStatus = null;
activity.uiImportError = null;
resetQueuedActivities();
renderActivities(currentActivities);
break;
}
if (!response.ok) { if (!response.ok) {
let message = 'Failed to import Komoot activity.'; let message = 'Failed to import Komoot activity.';
try { try {
@ -490,7 +500,9 @@
} }
} }
if (cancelled) { if (rateLimited) {
showStatus('Komoot rate limit reached. Import stopped. Please try again later.');
} else if (cancelled) {
showStatus(`Import stopped after the current activity. Imported ${importedCount} Komoot activit${importedCount === 1 ? 'y' : 'ies'}${failedCount > 0 ? `, ${failedCount} failed` : ''}.`); showStatus(`Import stopped after the current activity. Imported ${importedCount} Komoot activit${importedCount === 1 ? 'y' : 'ies'}${failedCount > 0 ? `, ${failedCount} failed` : ''}.`);
} else { } else {
showStatus(`Imported ${importedCount} Komoot activit${importedCount === 1 ? 'y' : 'ies'}${failedCount > 0 ? `, ${failedCount} failed` : ''}.`); showStatus(`Imported ${importedCount} Komoot activit${importedCount === 1 ? 'y' : 'ies'}${failedCount > 0 ? `, ${failedCount} failed` : ''}.`);