trackworktime icon indicating copy to clipboard operation
trackworktime copied to clipboard

Selected task not current

Open WildOrangutan opened this issue 4 years ago • 4 comments
trafficstars

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:

  1. Clock-in with task A
  2. Change task to task B
  3. Start new period
  4. Task changes back to A (I would expect it should remain at task B)
  5. Start new period
  6. Task changes to task B (correct)

WildOrangutan avatar Sep 07 '21 12:09 WildOrangutan

Did some quick debugging around here. It seems like timing related issue, due to database read, that happens immediately after write.

  1. Write new event (db starts writing event) (clockInAction())
  2. Read current task from most recent event. Use it to update currently selected task. (refreshView())
  3. 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 avatar Oct 02 '21 00:10 WildOrangutan

@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...

mathisdt avatar Oct 02 '21 05:10 mathisdt

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.

mathisdt avatar Oct 02 '21 05:10 mathisdt

@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.

WildOrangutan avatar Oct 02 '21 10:10 WildOrangutan