Skip to content

Commit ee2d2a9

Browse files
committed
i hit a crash in production with the stopwatch; this fixes it
1 parent af3b96d commit ee2d2a9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/packages/frontend/editors/stopwatch/editor.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ export default function EditorTime() {
3939
const { project_id, path, actions } = useFrameContext() as unknown as {
4040
project_id: string;
4141
path: string;
42-
actions: TimeActions;
42+
actions?: TimeActions;
4343
};
4444
const timers: List<any> | undefined = useRedux(["timers"], project_id, path);
4545
const error: string | undefined = useRedux(["error"], project_id, path);
4646

47+
if (timers == null || actions == null) {
48+
return <Loading />;
49+
}
50+
4751
function renderStopwatches(): ReactNode[] {
4852
if (timers == null) {
4953
return [];
@@ -64,7 +68,7 @@ export default function EditorTime() {
6468
setCountdown={
6569
data.countdown != null
6670
? (countdown) => {
67-
actions.setCountdown(data.id, countdown);
71+
actions?.setCountdown(data.id, countdown);
6872
}
6973
: undefined
7074
}
@@ -73,6 +77,9 @@ export default function EditorTime() {
7377
}
7478

7579
function clickButton(id: number, button: string): void {
80+
if (actions == null) {
81+
return;
82+
}
7683
switch (button) {
7784
case "reset":
7885
actions.resetStopwatch(id);
@@ -93,14 +100,14 @@ export default function EditorTime() {
93100
}
94101

95102
function setLabel(id: number, label: string): void {
96-
actions.setLabel(id, label);
103+
actions?.setLabel(id, label);
97104
}
98105

99106
function renderButtonBar(): ReactNode {
107+
if (actions == null) return null;
100108
return <ButtonBar actions={actions} />;
101109
}
102110

103-
if (timers == null) return <Loading />;
104111
return (
105112
<div className="smc-vfill">
106113
{error && <Alert type="error" message={`Error: ${error}`} />}

0 commit comments

Comments
 (0)