Merge pull request #164 from trails-cool/fix/wahoo-import-no-file
Fix Wahoo import crash for workouts without FIT files
This commit is contained in:
commit
4d954c3d6b
2 changed files with 11 additions and 5 deletions
|
|
@ -44,10 +44,13 @@ export async function action({ params, request }: Route.ActionArgs) {
|
|||
await updateTokens(connection.id, tokens);
|
||||
}
|
||||
|
||||
// Download and convert
|
||||
// Download and convert (if file available)
|
||||
const workout = { id: event.workoutId, name: "", type: "", startedAt: "", duration: null, distance: null, fileUrl: event.fileUrl };
|
||||
const fileBuffer = await provider.downloadFile(tokens, workout);
|
||||
const gpx = await provider.convertToGpx(fileBuffer);
|
||||
let gpx: string | null = null;
|
||||
if (workout.fileUrl) {
|
||||
const fileBuffer = await provider.downloadFile(tokens, workout);
|
||||
gpx = await provider.convertToGpx(fileBuffer);
|
||||
}
|
||||
|
||||
// Create activity
|
||||
const activityId = await createActivity(connection.userId, {
|
||||
|
|
|
|||
|
|
@ -86,8 +86,11 @@ export async function action({ params, request }: Route.ActionArgs) {
|
|||
fileUrl: fileUrl || undefined,
|
||||
};
|
||||
|
||||
const fileBuffer = await provider.downloadFile(tokens, workout);
|
||||
const gpx = await provider.convertToGpx(fileBuffer);
|
||||
let gpx: string | null = null;
|
||||
if (workout.fileUrl) {
|
||||
const fileBuffer = await provider.downloadFile(tokens, workout);
|
||||
gpx = await provider.convertToGpx(fileBuffer);
|
||||
}
|
||||
|
||||
const activityId = await createActivity(user.id, {
|
||||
name: workoutName || `${provider.name} workout`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue