Skip to content
18 changes: 18 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,23 @@ const App: React.FC = () => {
}));
}, [stopAlarm]);

const revertTimer = useCallback(() => {
if (!lastSetTime) return;

stopAlarm();
setShowTimeUp(false);

const restoredTotalSeconds = lastSetTime.minutes * 60 + lastSetTime.seconds;
setTimerState((prev) => ({
...prev,
minutes: lastSetTime.minutes,
seconds: lastSetTime.seconds,
timeRemaining: restoredTotalSeconds,
isRunning: false,
isPaused: false
}));
}, [lastSetTime, stopAlarm]);
Comment thread
tanahiro2010 marked this conversation as resolved.

// F12キーでデベロッパーツールを開く
useEffect(() => {
const handleKeyDown = async (event: KeyboardEvent) => {
Expand Down Expand Up @@ -1003,6 +1020,7 @@ const App: React.FC = () => {
onStart={startTimer}
onPause={pauseTimer}
onReset={resetTimer}
onRevertTime={revertTimer}
onSettings={openSettings}
onHelp={() => setShowHelp(true)}
onMinutesChange={(minutes) =>
Expand Down
5 changes: 5 additions & 0 deletions src/components/TimerControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const TimerControls: React.FC<TimerControlsProps> = ({
onStart,
onPause,
onReset,
onRevertTime,
onSettings,
onHelp,
onMinutesChange,
Expand Down Expand Up @@ -278,6 +279,10 @@ const TimerControls: React.FC<TimerControlsProps> = ({
<button className="control-btn help-btn" onClick={onHelp}>
Help
</button>

<button className="control-btn reset" onClick={onRevertTime}>
Restore Timer
</button>
Comment thread
tanahiro2010 marked this conversation as resolved.
</div>

{/* ボリュームコントローラー */}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface TimerControlsProps {
onStart: () => void;
onPause: () => void;
onReset: () => void;
onRevertTime: () => void;
Comment thread
tanahiro2010 marked this conversation as resolved.
onSettings: () => void;
onHelp: () => void;
onMinutesChange: (minutes: number) => void;
Expand Down