aau-giraf / weekplanner

Main repository of the Weekplanner tablet application
GNU General Public License v3.0
15 stars 3 forks source link

Timers are copied wrong #897

Open JakobTopholt opened 1 year ago

JakobTopholt commented 1 year ago

Timers are copied wrong when activities are copied

As it is now when you copy an activity with a timer attached both of the alarms are identical. This means that when you delete one of the activities the alarm from the other one is deleted as well.

Potential solutions When copying alarms give the new alarm a new unique ID in the database.

This issue is in weekplanner/api_client and is harder to solve than it sounds so probably low priority

Steps to reproduce:

  1. Create new activity in weekplan
  2. Add timer to activity
  3. Copy activity
  4. Go into original activity and remove alarm
  5. Go into weekplan
  6. Enter the copied activity
  7. Go back into the weekplan Now observe that both timers are gone even though only one was deleted
NonBinaryAtkHeli commented 1 year ago

After a PO meeting was held regarding the issue, it has been decided that we will remove all timer functionality for now, which is what this task is going to represent.

Klint02 commented 1 year ago

After meeting with the external PO, it has been decided that we will be keeping the timer in its current state. HOWEVER! We have decided to abandoned this issue for now, seeing as it cannot be solved in the weekplanner app (frontend), but must be solved in the backend. We could not find the exact way that activities are copied therefore forcing us to focus on other issues, given this issue's low priority.

A way to solve it in the backend as, Topholt mentioned, is to give the new activities a new timerkey instead of inserting the old timerkey. While this may seem easy, we have not been able to find out where in the backend the actual activity copies are being created.

For future reference. Here would be our method in full detail as to solve this issue:

  1. In the backend create an int that stores the original activity's timerkey value
  2. Based on the request send from weekplanner; create the new activities as temporary objects in the backend
  3. Create new timers in the database based on the original timer (preserving the StartTime and FullLength data) but setting "Paused" to 1, "Progress" to 0.
  4. Assign all the new timer's timerkeys to the activity copy's (the new timers can be identified by searching for all timers that match the "StartTime and "FullLength" of the original timer).
  5. Lastly store the new activity copy's in the database.

This would in theory create all the new activities and give them their own respectiv timers.