Skip to content

Commit 43fad18

Browse files
committed
merged dev
1 parent 442571b commit 43fad18

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/app/components/Diff.jsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@ import { useStoreContext } from '../store';
88
function Diff({ snapshot, show }) {
99
const [mainState] = useStoreContext();
1010
const { currentTab, tabs } = mainState;
11-
const { snapshots, viewIndex } = tabs[currentTab];
11+
const { snapshots, viewIndex, sliderIndex } = tabs[currentTab];
1212
let previous;
1313

14-
if (viewIndex === -1) {
15-
if (snapshots.length > 1) {
16-
previous = snapshots[snapshots.length - 2];
17-
} else {
18-
previous = undefined;
19-
}
20-
} else if (snapshots.length > 1) {
14+
// previous follows viewIndex or sliderIndex
15+
if (viewIndex !== -1) {
2116
previous = snapshots[viewIndex - 1];
2217
} else {
23-
[previous] = snapshots;
18+
previous = snapshots[sliderIndex - 1];
2419
}
2520

2621
const delta = diff(previous, snapshot);
22+
// returns html in string
2723
const html = formatters.html.format(delta, previous);
2824
if (show) formatters.html.showUnchanged();
2925
else formatters.html.hideUnchanged();

0 commit comments

Comments
 (0)