exer_log
exer_log copied to clipboard
Firebase config: add workoutId in documents returned from getWorkoutOnDate
Steps to reproduce
When main calendar widget is builded we use function getWorkoutOnDate on every element(day) of calendar, That function returns snapshots with workout documents, but without id field. It is not a problem with define id field in Workout object, but with data returned from Firebase (maybe problem with proper configuration of collection or something)
Expected behavior
WorkoutId field is required to proper workout remove process
void deleteWorkout(Workout workout) async {
for (Exercise exercise in workout.exercises) {
deleteExercise(exercise);
}
await firestoreInstance
.collection('users')
.doc(SharedPref.getStringAsync(USER_UID))
.collection('workouts')
.doc(workout.id)
.delete();
}
Actual behavior
Currently we collect workout data like this:
return FirebaseFirestore.instance
.collection('users')
.doc(SharedPref.getStringAsync(USER_UID))
.collection('workouts')
.where('date', isLessThan: after)
.where('date', isGreaterThan: before)
.snapshots();
we get last document from collection
workout.docs.last
the actual returned workout document/object looks like this:
{date: Timestamp(seconds=1663612760, nanoseconds=669000000), template: false, total_reps: 6, notes: , exercises: [Ohf06H1McAhQ9eqQON5o], name: w2, total_sets: 2, rating: , time: 0.0, type: , total_weight: 0.0}
so there is no id or workoutId field in above example :(
@KalleHallden can you take a look on this please?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.