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

Commit f801f6c

Browse files
committed
fix(client): modify presenter mode
1 parent da3b7b2 commit f801f6c

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Modal.setAppElement('#root');
2626

2727
const Iframe = ({ slideUrl, slideIndex }) => (
2828
<iframe
29-
src={`${slideUrl.replace(/slide=(\d?)/, `slide=${slideIndex}`)}`}
29+
src={`${slideUrl.replace(/slide-(\d?)/, `slide-${slideIndex}`)}`}
3030
width="100%"
3131
height="100%"
3232
/>
@@ -44,7 +44,7 @@ const Host = memo(({ slides, currentIndex, terminate, onChangeSlideIndex }) => {
4444
if (!presentationController) {
4545
const { origin, pathname } = new URL(window.location);
4646

47-
slideUrl = `${origin}${pathname}?sidebar=false&isLive=false#slide=`;
47+
slideUrl = `${origin}${pathname}?sidebar=false&reference=false&isLive=false#slide-`;
4848
presentationController = new PresentationController();
4949
}
5050

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Receiver as PresentationReceiver } from '../../presentationMode/Receive
99
import { WebRTC } from '../../utils/webrtc';
1010
import '../../../assets/style/view.css';
1111

12+
const slideWrapperClassName = '.swiper-container';
1213
let presentationReceiver = null;
1314
let webrtc = null;
1415
let currentVideoTag = null;
@@ -17,17 +18,18 @@ let currentLayer = null;
1718
const View = memo(({ slides, hash }) => {
1819
// need to declare here
1920
if (!presentationReceiver) {
20-
presentationReceiver = new PresentationReceiver();
21-
presentationReceiver.onChangePage((pageNum) => {
22-
if (window.slide) {
23-
window.slide.goToSlide(pageNum);
21+
window.onload = () => {
22+
const tag = document.querySelector(slideWrapperClassName);
23+
presentationReceiver = new PresentationReceiver();
2424

25+
presentationReceiver.onChangePage((pageNum) => {
26+
tag?.swiper?.slideTo(pageNum);
2527
// stop capturing
2628
if (webrtc && currentVideoTag) {
2729
stopCapturing(currentVideoTag);
2830
}
29-
}
30-
});
31+
});
32+
};
3133
}
3234

3335
// const [usedCanvas, changeCanvasState] = useState(false);

packages/client/src/entryPoints/Client.js

+19-14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render, hydrate } from 'react-dom';
33
import { fetchSlides } from '../utils/fetchSlides';
44
import { setTargetBlank } from '../utils/targetBlank';
55
import { AppContainer } from '../components/AppContainer';
6+
import { getSearchParams } from '../utils/getSearchParams';
67
import '../setup/css';
78

89
function createBody(slides = [], hash = 0) {
@@ -25,18 +26,22 @@ if (process.env.TARGET_BLANK) {
2526
}
2627

2728
if (process.env.NODE_ENV !== 'production') {
28-
(async () => {
29-
// for tree shaking
30-
const { Assistant } = await import('../components/Assistant');
31-
const el = document.createElement('div');
32-
33-
el.style.position = 'absolute';
34-
el.style.top = 0;
35-
el.style.width = '100%';
36-
el.style.zIndex = 10000;
37-
el.setAttribute('id', 'reference');
38-
document.body.appendChild(el);
39-
40-
render(<Assistant />, document.getElementById('reference'));
41-
})();
29+
const params = getSearchParams();
30+
31+
if (params.get('reference') !== 'false') {
32+
(async () => {
33+
// for tree shaking
34+
const { Assistant } = await import('../components/Assistant');
35+
const el = document.createElement('div');
36+
37+
el.style.position = 'absolute';
38+
el.style.top = 0;
39+
el.style.width = '100%';
40+
el.style.zIndex = 10000;
41+
el.setAttribute('id', 'reference');
42+
document.body.appendChild(el);
43+
44+
render(<Assistant />, document.getElementById('reference'));
45+
})();
46+
}
4247
}

packages/client/src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './components/SlideCore';

0 commit comments

Comments
 (0)