Skip to content

Commit 1d159b9

Browse files
authored
Merge pull request #308 from germanocaumo/quick-swap-fix
Revert "Merge pull request #288 from Tainan404/add-support-for-layout-swap"
2 parents c799dc1 + 7224036 commit 1d159b9

File tree

11 files changed

+14
-142
lines changed

11 files changed

+14
-142
lines changed

src/components/player/content/index.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Presentation from 'components/presentation';
44
import TldrawPresentation from 'components/tldraw';
55
import TldrawPresentationV2 from 'components/tldraw_v2';
66
import { getTldrawBbbVersion } from 'utils/tldraw';
7-
import { useCurrentInterval, useShouldShowScreenShare } from 'components/utils/hooks';
7+
import { useCurrentInterval } from 'components/utils/hooks';
88
import Screenshare from 'components/screenshare';
99
import Thumbnails from 'components/thumbnails';
1010
import FullscreenButton from 'components/player/buttons/fullscreen';
@@ -26,8 +26,6 @@ const Content = ({
2626
index,
2727
} = useCurrentInterval(storage.tldraw);
2828

29-
const shouldShowScreenshare = useShouldShowScreenShare();
30-
3129
if (layout.single) return null;
3230

3331
const isTldrawWhiteboard = storage.tldraw.length ||
@@ -60,19 +58,7 @@ const Content = ({
6058
/>
6159
<div className="top-content">
6260
{presentation}
63-
{layout.screenshare ? (
64-
// video-js doesn't mount properly when not mounted in time
65-
<span style={!shouldShowScreenshare ?{
66-
display: 'none',
67-
width: '100%',
68-
height: '100%'
69-
} : {
70-
width: '100%',
71-
height: '100%',
72-
}}>
73-
<Screenshare />
74-
</span>
75-
): null}
61+
{layout.screenshare ? <Screenshare /> : null}
7662
</div>
7763
<div className={cx('bottom-content', { 'inactive': fullscreen })}>
7864
<Thumbnails

src/components/presentation/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Canvas from './canvas';
1010
import {
1111
useCurrentContent,
1212
useCurrentIndex,
13-
useShouldShowScreenShare,
1413
} from 'components/utils/hooks';
1514
import { ID } from 'utils/constants';
1615
import storage from 'utils/data/storage';
@@ -61,11 +60,11 @@ const Presentation = () => {
6160
const viewBox = getViewBox(currentPanzoomIndex);
6261

6362
const started = currentPanzoomIndex !== -1;
64-
const shouldShowScreenshare = useShouldShowScreenShare();
63+
6564
return (
6665
<div
6766
aria-label={intl.formatMessage(intlMessages.aria)}
68-
className={cx('presentation-wrapper', { inactive: (currentContent !== ID.PRESENTATION && shouldShowScreenshare) })}
67+
className={cx('presentation-wrapper', { inactive: currentContent !== ID.PRESENTATION })}
6968
id={ID.PRESENTATION}
7069
>
7170
<div className={cx('presentation', { logo: !started })}>

src/components/thumbnails/index.js

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useMemo, useRef } from 'react';
1+
import React, { useEffect, useRef } from 'react';
22
import PropTypes from 'prop-types';
33
import {
44
defineMessages,
@@ -34,7 +34,7 @@ const propTypes = {
3434
};
3535

3636
const defaultProps = {
37-
handleSearch: () => {},
37+
handleSearch: () => { },
3838
interactive: false,
3939
search: [],
4040
};
@@ -44,6 +44,7 @@ const Thumbnails = ({
4444
interactive,
4545
search,
4646
}) => {
47+
const currentIndex = useCurrentIndex(storage.thumbnails);
4748
const interaction = useRef(false);
4849
const firstNode = useRef();
4950
const currentNode = useRef();
@@ -76,52 +77,6 @@ const Thumbnails = ({
7677
}
7778
});
7879

79-
const items = useMemo(()=> {
80-
const thumbnails = storage.thumbnails;
81-
const layoutSwap = storage.layoutSwap ?? [];
82-
const merged = [...thumbnails, ...layoutSwap];
83-
const sorted = merged.sort((a, b) => a.timestamp - b.timestamp);
84-
85-
const addThumbsForSwap = sorted.map((item, index, arr) => {
86-
const previousItem = arr[index - 1];
87-
const nextItem = arr[index + 1];
88-
if (item.hasOwnProperty('showScreenshare')) {
89-
if (!item.showScreenshare) {
90-
const previousThumbs = arr.slice(0, index)
91-
const Thumbnail = previousThumbs.find((t) => t.src && t.src !== 'screenshare');
92-
return {
93-
...item,
94-
src: Thumbnail?.src ?? '',
95-
alt: Thumbnail?.alt ?? '',
96-
};
97-
} else if (
98-
item.showScreenshare
99-
&& (nextItem && nextItem.src !== 'screenshare')
100-
&& (previousItem && previousItem.src !== 'screenshare')
101-
) {
102-
return {
103-
...item,
104-
src: 'screenshare',
105-
alt: 'screenshare',
106-
}
107-
}
108-
return null;
109-
}
110-
return item;
111-
}).filter((item) => item !== null);
112-
113-
const reworkIds = addThumbsForSwap.map((item, index) => {
114-
return {
115-
...item,
116-
id: index + 1,
117-
}
118-
});
119-
120-
return reworkIds;
121-
}, [storage.thumbnails, storage.layoutSwap]);
122-
123-
const currentIndex = useCurrentIndex(items);
124-
12580
return (
12681
<div
12782
aria-label={intl.formatMessage(intlMessages.aria)}
@@ -131,7 +86,7 @@ const Thumbnails = ({
13186
onMouseLeave={() => interaction.current = false}
13287
tabIndex="0"
13388
>
134-
{items.reduce((result, item, index) => {
89+
{storage.thumbnails.reduce((result, item, index) => {
13590
if (!isFiltered(index)) {
13691
const active = index === currentIndex;
13792

src/components/tldraw/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
useCurrentContent,
1919
useCurrentIndex,
2020
useCurrentInterval,
21-
useShouldShowScreenShare,
2221
} from 'components/utils/hooks';
2322
import { ID } from 'utils/constants';
2423
import storage from 'utils/data/storage';
@@ -118,7 +117,7 @@ const TldrawPresentation = ({ size }) => {
118117
const currentPanzoomIndex = useCurrentIndex(storage.panzooms);
119118
const currentSlideIndex = useCurrentIndex(storage.slides);
120119
const started = currentPanzoomIndex !== -1;
121-
const shouldShowScreenShare = useShouldShowScreenShare();
120+
122121
const result = SlideData(tldrawAPI);
123122

124123
let { assets, shapes, scaleRatio } = result;
@@ -157,7 +156,7 @@ const TldrawPresentation = ({ size }) => {
157156
return (
158157
<div
159158
aria-label={intl.formatMessage(intlMessages.aria)}
160-
className={cx('presentation-wrapper', { inactive: (currentContent !== ID.PRESENTATION && shouldShowScreenShare) })}
159+
className={cx('presentation-wrapper', { inactive: currentContent !== ID.PRESENTATION })}
161160
id={ID.PRESENTATION}
162161
>
163162
{!started

src/components/tldraw_v2/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
useCurrentContent,
1212
useCurrentIndex,
1313
useCurrentInterval,
14-
useShouldShowScreenShare,
1514
} from 'components/utils/hooks';
1615
import { ID } from 'utils/constants';
1716
import storage from 'utils/data/storage';
@@ -100,7 +99,6 @@ const TldrawPresentationV2 = ({ size }) => {
10099
const started = currentPanzoomIndex !== -1;
101100

102101
const result = SlideData(tldrawAPI);
103-
const shouldShowScreenshare = useShouldShowScreenShare();
104102

105103
let { assets, shapes, scaleRatio } = result;
106104
const {
@@ -157,7 +155,7 @@ const TldrawPresentationV2 = ({ size }) => {
157155
return (
158156
<div
159157
aria-label={intl.formatMessage(intlMessages.aria)}
160-
className={cx('presentation-wrapper', { inactive: (currentContent !== ID.PRESENTATION && shouldShowScreenshare) })}
158+
className={cx('presentation-wrapper', { inactive: currentContent !== ID.PRESENTATION })}
161159
id={ID.PRESENTATION}
162160
>{!started
163161
? <div className={cx('presentation', 'logo')} />

src/components/utils/hooks/index.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {
88
getCurrentDataIndex,
99
getCurrentDataInterval,
1010
} from 'utils/data';
11-
import storage from 'utils/data/storage';
12-
import { isEqual, isShowScreenshareAsContent } from 'utils/data/validators';
11+
import { isEqual } from 'utils/data/validators';
1312

1413
const useCurrentContent = () => {
1514
const [currentContent, setCurrentContent] = useState(ID.PRESENTATION);
@@ -29,24 +28,6 @@ const useCurrentContent = () => {
2928
return currentContent;
3029
};
3130

32-
const useShouldShowScreenShare = () => {
33-
const [shouldShowScreenShare, setShouldShowScreenShare] = useState(false);
34-
35-
useEffect(() => {
36-
const handleTimeUpdate = (event) => {
37-
const nextShouldShowScreenShare = isShowScreenshareAsContent(storage.layoutSwap, event.detail.time);
38-
if (shouldShowScreenShare !== nextShouldShowScreenShare) setShouldShowScreenShare(nextShouldShowScreenShare);
39-
};
40-
41-
document.addEventListener(EVENTS.TIME_UPDATE, handleTimeUpdate);
42-
return () => {
43-
document.removeEventListener(EVENTS.TIME_UPDATE, handleTimeUpdate);
44-
};
45-
}, [shouldShowScreenShare]);
46-
47-
return shouldShowScreenShare;
48-
}
49-
5031
const useCurrentIndex = (data) => {
5132
const [currentIndex, setCurrentIndex] = useState(-1);
5233

@@ -96,5 +77,4 @@ export {
9677
useCurrentContent,
9778
useCurrentIndex,
9879
useCurrentInterval,
99-
useShouldShowScreenShare,
10080
};

src/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const files = {
2727
shapes: 'shapes.svg',
2828
tldraw: 'tldraw.json',
2929
videos: 'external_videos.json',
30-
layout: 'layout.xml',
3130
};
3231

3332
const locale = { default: 'en' };

src/utils/builder.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ const buildShapes = result => {
336336
data.thumbnails = buildThumbnails(data.slides);
337337
data.canvases = buildCanvases(g, data.slides);
338338
}
339-
data.slides = data.slides.filter(slide => !slide.src.includes(ID.DESKSHARE));
339+
340340
return data;
341341
};
342342

@@ -371,22 +371,6 @@ const buildTldraw = result => {
371371
return tldraw;
372372
}
373373

374-
const buildLayout = result => {
375-
const { recording } = result;
376-
377-
if (recording?.event) {
378-
const newData = convertToArray(recording.event).map(layout => {
379-
return {
380-
timestamp: parseFloat(layout._timestamp),
381-
showScreenshare: layout._show_screenshare === 'true',
382-
}
383-
});
384-
return newData;
385-
}
386-
387-
return [];
388-
};
389-
390374
const buildPanzooms = result => {
391375
let data = [];
392376
const { recording } = result;
@@ -583,9 +567,6 @@ const build = (filename, value) => {
583567
case config.shapes:
584568
data = buildShapes(result);
585569
break;
586-
case config.layout:
587-
data = buildLayout(result);
588-
break;
589570
default:
590571
logger.debug('unhandled', 'xml', filename);
591572
reject(filename);

src/utils/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const ID = {
5252
USERS: 'users',
5353
VIDEOS: 'videos',
5454
WEBCAMS: 'webcams',
55-
LAYOUT: 'layout',
5655
};
5756

5857
const CONTENT = [

src/utils/data/storage.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ const storage = {
165165
videos: hasProperty(DATA, ID.VIDEOS),
166166
presentation: hasProperty(DATA, ID.SHAPES),
167167
screenshare: hasProperty(DATA, ID.SCREENSHARE),
168-
layoutSwap: hasProperty(DATA, ID.LAYOUT),
169168
};
170169
},
171170
get content() {
@@ -177,7 +176,6 @@ const storage = {
177176
videos: !isEmpty(this.videos),
178177
presentation: hasPresentation(this.slides),
179178
screenshare: !isEmpty(this.screenshare),
180-
layoutSwap: !isEmpty(this.layoutSwap),
181179
};
182180
},
183181
get alternates() {
@@ -240,9 +238,6 @@ const storage = {
240238

241239
return DATA[ID.THUMBNAILS];
242240
},
243-
get layoutSwap() {
244-
return DATA[ID.LAYOUT];
245-
},
246241
get tldraw() {
247242
return DATA[ID.TLDRAW];
248243
},

0 commit comments

Comments
 (0)