From 01002f8eb36678c11b1a1c2e9f586cedf8431c64 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 4 Mar 2022 16:21:03 +0300 Subject: [PATCH] Attachment Modal: Support scheduling (#1740) --- .../middle/composer/AttachmentModal.scss | 15 ++++++ .../middle/composer/AttachmentModal.tsx | 49 ++++++++++++++++--- src/components/middle/composer/Composer.tsx | 4 ++ .../middle/composer/CustomSendMenu.tsx | 5 +- src/components/ui/Menu.scss | 8 +-- 5 files changed, 67 insertions(+), 14 deletions(-) diff --git a/src/components/middle/composer/AttachmentModal.scss b/src/components/middle/composer/AttachmentModal.scss index 3e120f1ae..3ac0ed4b0 100644 --- a/src/components/middle/composer/AttachmentModal.scss +++ b/src/components/middle/composer/AttachmentModal.scss @@ -128,4 +128,19 @@ border-radius: var(--border-radius-default); } } + + &--send-wrapper { + position: relative; + } + + .CustomSendMenu { + bottom: auto; + + .is-pointer-env & > .backdrop { + width: 100%; + top: -2.25rem; + bottom: auto; + height: 2.75rem; + } + } } diff --git a/src/components/middle/composer/AttachmentModal.tsx b/src/components/middle/composer/AttachmentModal.tsx index 1924abfbc..061a1495a 100644 --- a/src/components/middle/composer/AttachmentModal.tsx +++ b/src/components/middle/composer/AttachmentModal.tsx @@ -17,6 +17,7 @@ import useMentionTooltip from './hooks/useMentionTooltip'; import useEmojiTooltip from './hooks/useEmojiTooltip'; import useLang from '../../../hooks/useLang'; import useFlag from '../../../hooks/useFlag'; +import useContextMenuHandlers from '../../../hooks/useContextMenuHandlers'; import { useStateRef } from '../../../hooks/useStateRef'; import Button from '../../ui/Button'; @@ -25,6 +26,7 @@ import File from '../../common/File'; import MessageInput from './MessageInput'; import MentionTooltip from './MentionTooltip'; import EmojiTooltip from './EmojiTooltip.async'; +import CustomSendMenu from './CustomSendMenu.async'; import './AttachmentModal.scss'; @@ -33,7 +35,9 @@ export type OwnProps = { threadId: number; attachments: ApiAttachment[]; caption: string; + canShowCustomSendMenu?: boolean; isReady?: boolean; + isChatWithSelf?: boolean; currentUserId?: string; groupChatMembers?: ApiChatMember[]; recentEmojis: string[]; @@ -44,6 +48,8 @@ export type OwnProps = { onSend: () => void; onFileAppend: (files: File[], isQuick: boolean) => void; onClear: () => void; + onSilentSend: () => void; + openCalendar: () => void; }; const DROP_LEAVE_TIMEOUT_MS = 150; @@ -53,7 +59,9 @@ const AttachmentModal: FC = ({ threadId, attachments, caption, + canShowCustomSendMenu, isReady, + isChatWithSelf, currentUserId, groupChatMembers, recentEmojis, @@ -64,8 +72,12 @@ const AttachmentModal: FC = ({ onSend, onFileAppend, onClear, + onSilentSend, + openCalendar, }) => { const captionRef = useStateRef(caption); + // eslint-disable-next-line no-null/no-null + const mainButtonRef = useStateRef(null); const hideTimeoutRef = useRef(); const prevAttachments = usePrevious(attachments); const renderingAttachments = attachments.length ? attachments : prevAttachments; @@ -100,6 +112,13 @@ const AttachmentModal: FC = ({ useEffect(() => (isOpen ? captureEscKeyListener(onClear) : undefined), [isOpen, onClear]); + const { + isContextMenuOpen: isCustomSendMenuOpen, + handleContextMenu, + handleContextMenuClose, + handleContextMenuHide, + } = useContextMenuHandlers(mainButtonRef, !canShowCustomSendMenu || !isOpen); + const sendAttachments = useCallback(() => { if (isOpen) { onSend(); @@ -183,14 +202,28 @@ const AttachmentModal: FC = ({
{title}
- +
+ + {canShowCustomSendMenu && ( + + )} +
); } diff --git a/src/components/middle/composer/Composer.tsx b/src/components/middle/composer/Composer.tsx index aaec7d629..e48639230 100644 --- a/src/components/middle/composer/Composer.tsx +++ b/src/components/middle/composer/Composer.tsx @@ -849,16 +849,20 @@ const Composer: FC = ({ = ({ - isOpen, onSilentSend, onScheduleSend, onClose, onCloseAnimationEnd, + isOpen, isOpenToBottom = false, onSilentSend, onScheduleSend, onClose, onCloseAnimationEnd, }) => { const [handleMouseEnter, handleMouseLeave] = useMouseInside(isOpen, onClose); @@ -29,7 +30,7 @@ const CustomSendMenu: FC = ({ isOpen={isOpen} autoClose positionX="right" - positionY="bottom" + positionY={isOpenToBottom ? 'top' : 'bottom'} className="CustomSendMenu" onClose={onClose} onCloseAnimationEnd={onCloseAnimationEnd} diff --git a/src/components/ui/Menu.scss b/src/components/ui/Menu.scss index e7e316743..fafa7b37c 100644 --- a/src/components/ui/Menu.scss +++ b/src/components/ui/Menu.scss @@ -43,10 +43,6 @@ transition: opacity 0.15s !important; } - body.has-open-dialog & { - transition: none !important; - } - --offset-y: calc(100% + 0.5rem); --offset-x: 0; @@ -71,6 +67,10 @@ } } + body.has-open-dialog &:not(.CustomSendMenu) .bubble { + transition: none !important; + } + .footer { padding: 0.5rem 0; background: var(--color-chat-hover);