naturapeute/aposto-app

Bug when updating total duration to a duration smaller than the sum of selected service durations

Closed this issue · 2 comments

When updating the total duration to a duration smaller than the sum of selected service durations, the remaining duration bar appears while there is not remaining duration.

It is due to the remaining duration calculation that returns a negative value. As it is, it is considered as a remaining duration and the timeline is displayed.

We can fix it easily by returning 0 from remaining duration calculation when the result is negative. Nevertheless, it raises an other issue : what happen to already selected services ? Should we shrink the last service according to the new total duration ? If so, what happen when the last service shrink to 0 and, more, if there new total duration does not cover the second to last neither ?

IMO, a solution would be to leave the selected services as they are when updating the total duration but to consider the session description as invalid and this way disable the send button (the send button status is not based on session description validity yet, but it is planned).

Best thing would be to shrink the latest, remove it if it's 0, same for previous. Starting from last.

If that's a pain, just clearing the session if fine: selecting the time of a session if a precondition for defining the session.

Keep it simple.

@vinyll I personally like the second option. It makes more sense, I think the first one will not be expected by users.