Skip to content

Commit ca1b6df

Browse files
authored
Fixed reset not considering the message's argument (#1110)
Before this, LiveSplitOne would not consider the server's "saveAttempt" argument when receiving a reset command. This makes sure the command is full taken into account, by asking the user if they wish to save the times if and only if the command has not provided the "saveAttempt" argument.
1 parent 6b4c89a commit ca1b6df

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/ui/views/TimerView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function View({
180180
<button
181181
aria-label="Reset"
182182
disabled={currentPhase === TimerPhase.NotRunning}
183-
onClick={(_) => commandSink.reset()}
183+
onClick={(_) => commandSink.reset(undefined)}
184184
>
185185
<X strokeWidth={3.5} />
186186
</button>

src/util/LSOCommandSink.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ export class LSOCommandSink {
111111
return result;
112112
}
113113

114-
public async reset(): Promise<CommandResult> {
114+
public async reset(updateSplits?: boolean): Promise<CommandResult> {
115115
if (this.locked) {
116116
return CommandError.Busy;
117117
}
118118

119-
let updateSplits = true;
120-
if (this.timer.currentAttemptHasNewBestTimes()) {
119+
if (updateSplits === undefined && this.timer.currentAttemptHasNewBestTimes()) {
121120
const [result] = await showDialog({
122121
title: "Save Best Times?",
123122
description:
@@ -130,7 +129,7 @@ export class LSOCommandSink {
130129
updateSplits = result === 0;
131130
}
132131

133-
const result = this.timer.reset(updateSplits) as CommandResult;
132+
const result = this.timer.reset(updateSplits ?? true) as CommandResult;
134133

135134
if (isEvent(result)) {
136135
this.callbacks.handleEvent(result);

0 commit comments

Comments
 (0)