trackworktime
trackworktime copied to clipboard
Selected task not current
When you change task, and tap "start new period", task changes to previously used task.
I'm not sure if this is the intended behavior, but selected task seems to be one that was previously selected.
Reproduce:
- Clock-in with task A
- Change task to task B
- Start new period
- Task changes back to A (I would expect it should remain at task B)
- Start new period
- Task changes to task B (correct)
Did some quick debugging around here. It seems like timing related issue, due to database read, that happens immediately after write.
- Write new event (db starts writing event) (
clockInAction()) - Read current task from most recent event. Use it to update currently selected task. (
refreshView()) - New event is finished writing
By periodically pressing "new period", you can actually alternate between tasks A and B.
Not completely sure what to do atm, other than refactor a lot of stuff around database.
@WildOrangutan If you want a big task, you could revive #23 and introduce a database framework. But, on the other hand, I don't know exactly if that would fix the problem at hand...
Another possible way would be to hold only the task used for the last clock-in inside a variable (only for this use case). If the variable is null, the current mechanism would be used (read from last event in database), but if it is filled, the UI could use it.
@WildOrangutan If you want a big task, you could revive #23 and introduce a database framework. But, on the other hand, I don't know exactly if that would fix the problem at hand...
That would definitely make sense. Room with RxJava would help in this case.
Another possible way would be to hold only the task used for the last clock-in inside a variable (only for this use case). If the variable is
null, the current mechanism would be used (read from last event in database), but if it is filled, the UI could use it.
I will consider it later. I'm a bit worried too much of this checks plainly inside DAO would degrade codebase.