Skip to content

Commit dd69b9e

Browse files
committed
timetravel git -- tooltips of times not displayed properly
- this just broke when switching to logical time in non-git mode
1 parent 74d461a commit dd69b9e

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

src/packages/frontend/frame-editors/time-travel-editor/navigation-slider.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface Props {
1313
versions?: List<number>;
1414
version?: number;
1515
setVersion: (number) => void;
16-
actions;
16+
wallTime: (number) => number;
1717
}
1818

1919
export function NavigationSlider({
@@ -31,15 +31,15 @@ function NavigationSliderNoMarks({
3131
version,
3232
versions,
3333
setVersion,
34-
actions,
34+
wallTime,
3535
}: Props) {
3636
const { isVisible } = useFrameContext();
3737
if (versions == null || version == null || !isVisible) {
3838
return null;
3939
}
4040

4141
const renderTooltip = (index) => {
42-
const date = actions.wallTime(versions.get(index));
42+
const date = wallTime(versions.get(index));
4343
if (date == null) return; // shouldn't happen
4444
return <TimeAgo date={date} />;
4545
};
@@ -65,12 +65,12 @@ function NavigationSliderMarks({
6565
version,
6666
versions,
6767
setVersion,
68-
actions,
68+
wallTime,
6969
}: Props) {
7070
const { isVisible } = useFrameContext();
7171

7272
const renderTooltip = (version) => {
73-
return <TimeAgo date={new Date(actions.wallTime(version))} />;
73+
return <TimeAgo date={new Date(wallTime(version))} />;
7474
};
7575

7676
const marks = useMemo(() => {

src/packages/frontend/frame-editors/time-travel-editor/range-slider.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface Props {
2121
version1?: number;
2222
setVersion0: (number) => void;
2323
setVersion1: (number) => void;
24-
actions;
24+
wallTime: (number) => number;
2525
}
2626

2727
export function RangeSlider({ marks, ...props }: Props & { marks?: boolean }) {
@@ -38,7 +38,7 @@ function RangeSliderNoMarks({
3838
version1,
3939
setVersion0,
4040
setVersion1,
41-
actions,
41+
wallTime,
4242
}: Props) {
4343
const { isVisible } = useFrameContext();
4444

@@ -63,7 +63,7 @@ function RangeSliderNoMarks({
6363
};
6464

6565
const renderTooltip = (index) => {
66-
const d = actions.wallTime(versions.get(index));
66+
const d = wallTime(versions.get(index));
6767
if (d == null) {
6868
// shouldn't happen
6969
return;
@@ -114,7 +114,7 @@ function RangeSliderMarks({
114114
version1,
115115
setVersion0,
116116
setVersion1,
117-
actions,
117+
wallTime,
118118
}: Props) {
119119
const { isVisible } = useFrameContext();
120120

@@ -150,7 +150,7 @@ function RangeSliderMarks({
150150
};
151151

152152
const renderTooltip = (version) => {
153-
const date = new Date(actions.wallTime(version));
153+
const date = new Date(wallTime(version));
154154
if (version == version0) {
155155
// Workaround fact that the left label is NOT VISIBLE
156156
// if it is close to the right, which makes this whole

src/packages/frontend/frame-editors/time-travel-editor/time-travel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// Time travel editor react component
77

8-
import { useEffect, useState } from "react";
8+
import { useEffect, useMemo, useState } from "react";
99
import { Button, Checkbox, Space, Tooltip } from "antd";
1010
import { Map } from "immutable";
1111
import {
@@ -160,6 +160,10 @@ export function TimeTravel(props: Props) {
160160
}
161161
}, [version, version0, version1, gitMode, changesMode]);
162162

163+
const wallTime = useMemo(() => {
164+
return gitMode ? (version) => version : props.actions.wallTime;
165+
}, [gitMode, props.actions]);
166+
163167
useEffect(() => {
164168
saveState(props.actions, {
165169
id: props.id,
@@ -328,7 +332,7 @@ export function TimeTravel(props: Props) {
328332
setVersion={setVersion}
329333
versions={gitMode ? gitVersions : versions}
330334
marks={marks}
331-
actions={props.actions}
335+
wallTime={wallTime}
332336
/>
333337
);
334338
};
@@ -345,7 +349,7 @@ export function TimeTravel(props: Props) {
345349
version1={version1}
346350
setVersion1={setVersion1}
347351
marks={marks}
348-
actions={props.actions}
352+
wallTime={wallTime}
349353
/>
350354
);
351355
};

0 commit comments

Comments
 (0)