Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make invalid timer states unrepresentable #818

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

CryZe
Copy link
Collaborator

@CryZe CryZe commented Jun 15, 2024

This refactors the internals of the Timer, such that it's impossible for different fields to contain conflicting information. This is done by factoring out an ActiveAttempt struct that only exists when there is an active attempt. Additionally inside it differentiates between the attempt having ended or not. The not ended state has a split index and an optional pause time, whereas the ended state has the date time of when the attempt ended.

This does not yet touch the public API of the Timer. Factoring out the notion of an active attempt and making sure invalid states are unrepresentable is done so we can soon explore the possibility of storing an active attempt in the splits file.

cc #266 #156

@CryZe CryZe added enhancement An improvement for livesplit-core. code quality Affects the quality of the code. labels Jun 15, 2024
@CryZe CryZe requested a review from wooferzfg June 15, 2024 12:33
@CryZe CryZe added this to the v0.14 milestone Jun 15, 2024
This refactors the internals of the `Timer`, such that it's impossible
for different fields to contain conflicting information. This is done by
factoring out an `ActiveAttempt` struct that only exists when there is
an active attempt. Additionally inside it differentiates between the
attempt having ended or not. The not ended state has a split index and
an optional pause time, whereas the ended state has the date time of
when the attempt ended.

This does not yet touch the public API of the `Timer`. Factoring out the
notion of an active attempt and making sure invalid states are
unrepresentable is done so we can soon explore the possibility of
storing an active attempt in the splits file.
@CryZe CryZe merged commit 4ebb4bb into LiveSplit:master Jun 15, 2024
70 checks passed
@CryZe CryZe deleted the active-attempt branch June 15, 2024 13:50
AlexKnauth added a commit to AlexKnauth/livesplit-core that referenced this pull request Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Affects the quality of the code. enhancement An improvement for livesplit-core.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant