import React, { useEffect } from 'react'; // tslint:disable: use-simple-attributes no-submodule-imports import { useDispatch } from 'react-redux'; import { resetOverlayMode, setOverlayMode } from '../../../../state/ducks/section'; import useKey from 'react-use/lib/useKey'; import styled from 'styled-components'; import { SessionIcon, SessionIconType } from '../../../icon'; import { ContactsListWithBreaks } from './ContactsListWithBreaks'; import { isEmpty, isString } from 'lodash'; const StyledActionRow = styled.button` border: none; display: flex; align-items: center; border-bottom: 1px var(--border-color) solid; transition-duration: 0.25s; width: 100%; &:first-child { border-top: 1px var(--border-color) solid; } :hover { background: var(--conversation-tab-background-hover-color); } `; export const StyledChooseActionTitle = styled.span` color: var(--text-primary-color); font-size: 18px; padding: var(--margins-xs) var(--margins-lg); `; const StyledIcon = styled.div` width: 58px; `; const IconOnActionRow = (props: { iconType: SessionIconType }) => { return ( ); }; export const OverlayChooseAction = () => { const dispatch = useDispatch(); function closeOverlay() { dispatch(resetOverlayMode()); } function openNewMessage() { dispatch(setOverlayMode('message')); } function openCreateGroup() { dispatch(setOverlayMode('closed-group')); } function openJoinCommunity() { dispatch(setOverlayMode('open-group')); } useKey('Escape', closeOverlay); function handlePaste(event: ClipboardEvent) { event.preventDefault(); const pasted = event.clipboardData?.getData('text'); if (pasted && isString(pasted) && !isEmpty(pasted)) { if (pasted.startsWith('http') || pasted.startsWith('https')) { openJoinCommunity(); } else if (pasted.startsWith('05')) { openNewMessage(); } } } useEffect(() => { document?.addEventListener('paste', handlePaste); return () => { document?.removeEventListener('paste', handlePaste); }; }, []); return (
{window.i18n('newMessage')} {window.i18n('createGroup')} {window.i18n('joinOpenGroup')}
); };