/* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */ import React from 'react'; import PropTypes from 'prop-types'; import './StickerBoard.scss'; import initMatrix from '../../../client/initMatrix'; import { getRelevantPacks } from '../emoji-board/custom-emoji'; import Text from '../../atoms/text/Text'; import ScrollView from '../../atoms/scroll/ScrollView'; function StickerBoard({ roomId, onSelect }) { const mx = initMatrix.matrixClient; const room = mx.getRoom(roomId); const parentIds = initMatrix.roomList.getAllParentSpaces(room.roomId); const parentRooms = [...parentIds].map((id) => mx.getRoom(id)); const packs = getRelevantPacks( mx, [room, ...parentRooms], ).filter((pack) => pack.getStickers().length !== 0); function isTargetNotSticker(target) { return target.classList.contains('sticker-board__sticker') === false; } function getStickerData(target) { const mxc = target.getAttribute('data-mx-sticker'); const body = target.getAttribute('title'); const httpUrl = target.getAttribute('src'); return { mxc, body, httpUrl }; } const handleOnSelect = (e) => { if (isTargetNotSticker(e.target)) return; const stickerData = getStickerData(e.target); onSelect(stickerData); }; const renderPack = (pack) => (