fix: append to track body in /end too, and save new track in /add

This commit is contained in:
Paul Bienkowski 2020-11-22 10:46:58 +01:00
parent 33e8cbdb83
commit 7460661607

View file

@ -184,6 +184,9 @@ router.post(
track.trackData = trackData._id;
track.author = user;
await track.save()
await trackData.save();
// remember which is the actively building track for this user
currentTracks.set(user.id, track._id);
@ -240,6 +243,9 @@ router.post(
throw new Error('current user active track is gone, retry upload');
}
track.body += req.body.track.body;
await track.save();
const trackData = await TrackData.findById(track.trackData);
trackData.points = Array.from(parseTrackPoints(track.body));
await trackData.save();