chiyadev / genshin-schedule

🕑 Genshin farming scheduler
https://genshin.chiya.dev
MIT License
72 stars 17 forks source link

Disallow editing fields during preview #67

Open ImmortalZypther opened 3 years ago

ImmortalZypther commented 3 years ago

If you click > to preview the resin amount tomorrow, then click any of the buttons to subtract resin, and then click < to return to your current time, you'll have negative resin that shows as 0. Clicking > again won't fix the issue, the preview will act like usual and add hours to simulate regeneration without touching the actual number. image

luaneko commented 3 years ago

This is working as intended as far as I'm concerned. If you modify resin value and go back in time, the extrapolated value will be negative, but it's not possible to have negative resins, hence it's clamped in the range [0, 160].

The same behavior can be observed when marking tasks as done while previewing the next few days. I think this is a logical behavior.

The only "fix" for this might be to disallow editing things altogether while in preview.

ImmortalZypther commented 3 years ago

As logical as it is, I don't think anybody intends to have negative resin.

If you look at the times, you'll see that even thought it shows as 0, it's still being calculated as if it were a negative number.

Disallowing editing things while in the preview is a good fix, but you could alternatively make it not touch your resin in the present since resin you edit in the "future" shouldn't affect the resin you have in the present.

luaneko commented 3 years ago

you could alternatively make it not touch your resin in the present since resin you edit in the "future" shouldn't affect the resin you have in the present.

It's definitely possible, but I think the complexity required code-wise to address this edge case makes it not worth pursuing. This will require us to clone another instance of the data store for previewing, but the current code isn't written with this in mind.

I think disabling edits during preview is a practical way to go. Other issues should be prioritized, but I'll keep this open in case someone else wants to tackle it.