Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/components/thumbnails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const propTypes = {
};

const defaultProps = {
handleSearch: () => {},
handleSearch: () => { },
interactive: false,
search: [],
};
Expand Down Expand Up @@ -76,29 +76,34 @@ const Thumbnails = ({
}
});

const items = useMemo(()=> {
const items = useMemo(() => {
const thumbnails = storage.thumbnails;
const layoutSwap = storage.layoutSwap ?? [];
const merged = [...thumbnails, ...layoutSwap];
const sorted = merged.sort((a, b) => a.timestamp - b.timestamp);

const addThumbsForSwap = sorted.map((item, index, arr) => {
const previousItem = arr[index - 1];
const nextItem = arr[index + 1];
if (item.hasOwnProperty('showScreenshare')) {
if (!item.showScreenshare) {
const previousThumbs = arr.slice(0, index)
const Thumbnail = previousThumbs.find((t) => t.src && t.src !== 'screenshare');
return {
...item,
src: Thumbnail?.src ?? '',
alt: Thumbnail?.alt ?? '',
};
// don't add if the src is the same as before
if (Thumbnail?.src === previousItem?.src) {
return null;
} else {
return {
...item,
src: Thumbnail?.src ?? '',
alt: Thumbnail?.alt ?? '',
};
}
} else if (
item.showScreenshare
&& (nextItem && nextItem.src !== 'screenshare')
&& (previousItem && previousItem.src !== 'screenshare')
) {
item.showScreenshare
&& (nextItem && nextItem.src !== 'screenshare')
&& (previousItem && previousItem.src !== 'screenshare')
) {
return {
...item,
src: 'screenshare',
Expand All @@ -116,9 +121,9 @@ const Thumbnails = ({
id: index + 1,
}
});

return reworkIds;
}, [storage.thumbnails, storage.layoutSwap]);
}, []);

const currentIndex = useCurrentIndex(items);

Expand Down