File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,18 @@ import { useStoreContext } from '../store';
8
8
function Diff ( { snapshot, show } ) {
9
9
const [ mainState ] = useStoreContext ( ) ;
10
10
const { currentTab, tabs } = mainState ;
11
- const { snapshots, viewIndex } = tabs [ currentTab ] ;
11
+ const { snapshots, viewIndex, sliderIndex } = tabs [ currentTab ] ;
12
12
let previous ;
13
13
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 ) {
21
16
previous = snapshots [ viewIndex - 1 ] ;
22
17
} else {
23
- [ previous ] = snapshots ;
18
+ previous = snapshots [ sliderIndex - 1 ] ;
24
19
}
25
20
26
21
const delta = diff ( previous , snapshot ) ;
22
+ // returns html in string
27
23
const html = formatters . html . format ( delta , previous ) ;
28
24
if ( show ) formatters . html . showUnchanged ( ) ;
29
25
else formatters . html . hideUnchanged ( ) ;
You can’t perform that action at this time.
0 commit comments