Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 661792f

Browse files
committed
fix(client): modify fragment
1 parent 3d3c306 commit 661792f

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

packages/client/src/components/ContentView/Base.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export const Base = memo(() => {
1414
swiper?.slideTo(currentIndex);
1515
}, [currentIndex]);
1616

17-
const keyboardListener = ({ key }) => {
18-
if (key === 'ArrowRight') {
19-
dispatch(updateCurrentIndex('+'));
20-
} else if (key === 'ArrowLeft') {
21-
dispatch(updateCurrentIndex('-'));
22-
}
23-
};
24-
2517
useEffect(() => {
18+
const keyboardListener = ({ key }) => {
19+
if (key === 'ArrowRight') {
20+
dispatch(updateCurrentIndex('+'));
21+
} else if (key === 'ArrowLeft') {
22+
dispatch(updateCurrentIndex('-'));
23+
}
24+
};
25+
2626
if (window.innerWidth <= 768) {
2727
(async () => {
2828
const { swipeEvent } = await import('../../utils/swipeEvent');

packages/client/src/components/ContentView/Host.js

+20-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { formatTime } from '../../utils/formatTime';
1818
import { WebRTC } from '../../utils/webrtc';
1919
import '../../../assets/style/host.css';
2020

21-
const Iframe = ({ slideUrl, slideIndex }) => (
21+
const Iframe = ({ slideUrl, slideIndex, fragment }) => (
2222
<iframe
2323
src={`${slideUrl.replace(/slide-(\d?)/, `slide-${slideIndex}`)}`}
2424
width="100%"
@@ -31,7 +31,7 @@ let recordedStartedTime = 0;
3131

3232
const Host = () => {
3333
const {
34-
state: { slides, currentIndex },
34+
state: { slides, currentIndex, currentFragmentSteps },
3535
dispatch: dispatchSlides,
3636
} = useSlides();
3737
const [slideUrl, setSlideUrl] = useState(null);
@@ -112,10 +112,6 @@ const Host = () => {
112112
setEmptyRecordedTimelineStatus(true);
113113
};
114114

115-
useEffect(() => {
116-
webrtc?.setupRecording();
117-
}, [webrtc]);
118-
119115
const setupRecording = () => {
120116
if (!webrtc) {
121117
setWebrtc(new WebRTC());
@@ -131,6 +127,10 @@ const Host = () => {
131127
setUsedAudio(false);
132128
};
133129

130+
useEffect(() => {
131+
webrtc?.setupRecording();
132+
}, [webrtc]);
133+
134134
useEffect(() => {
135135
presentationControllerRef.current = presentationController;
136136

@@ -224,11 +224,23 @@ const Host = () => {
224224
<div className="host-right-box">
225225
<div className="host-slide-layer">
226226
<h2>Current</h2>
227-
{slideUrl && <Iframe slideUrl={slideUrl} slideIndex={currentIndex + 1} />}
227+
{slideUrl && (
228+
<Iframe
229+
slideUrl={slideUrl}
230+
slideIndex={currentIndex + 1}
231+
fragment={currentFragmentSteps}
232+
/>
233+
)}
228234
</div>
229235
<div className="host-slide-layer">
230236
<h2>Next</h2>
231-
{slideUrl && <Iframe slideUrl={slideUrl} slideIndex={currentIndex + 2} />}
237+
{slideUrl && (
238+
<Iframe
239+
slideUrl={slideUrl}
240+
slideIndex={currentIndex + 2}
241+
fragment={currentFragmentSteps}
242+
/>
243+
)}
232244
</div>
233245
</div>
234246
<div className="host-bottom-box">

packages/client/src/utils/getSlideIndex.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ export function getSlideIndex({ next, slides, currentIndex, timeline, currentFra
77

88
if (Array.isArray(timeline[nextIndex])) {
99
nextCurrentFragmentSteps = 0;
10-
} else {
10+
} else if (Array.isArray(timeline[currentIndex])) {
1111
nextCurrentFragmentSteps = currentFragmentSteps + 1;
12+
} else {
13+
nextCurrentFragmentSteps = 0;
1214
}
1315
} else if (next === '-') {
1416
nextIndex = Math.max(currentIndex - 1, 0);
1517

1618
// restore fragments
1719
if (Array.isArray(timeline[nextIndex])) {
1820
nextCurrentFragmentSteps = timeline[nextIndex].length;
19-
} else {
21+
} else if (Array.isArray(timeline[currentIndex])) {
2022
nextCurrentFragmentSteps = currentFragmentSteps - 1;
23+
} else {
24+
nextCurrentFragmentSteps = 0;
2125
}
2226
}
2327

0 commit comments

Comments
 (0)