diff --git a/src/api/gramjs/methods/messages.ts b/src/api/gramjs/methods/messages.ts index a42abe6c6..496df9294 100644 --- a/src/api/gramjs/methods/messages.ts +++ b/src/api/gramjs/methods/messages.ts @@ -256,6 +256,7 @@ export function sendMessage( noWebPage, sendAs, shouldUpdateStickerSetOrder, + wasDrafted, }: { chat: ApiChat; lastMessageId?: number; @@ -274,6 +275,7 @@ export function sendMessage( noWebPage?: boolean; sendAs?: ApiPeer; shouldUpdateStickerSetOrder?: boolean; + wasDrafted?: boolean; }, onProgress?: ApiOnProgress, ) { @@ -298,6 +300,7 @@ export function sendMessage( id: localMessage.id, chatId: chat.id, message: localMessage, + wasDrafted, }); // This is expected to arrive after `updateMessageSendSucceeded` which replaces the local ID, @@ -1284,6 +1287,7 @@ export async function forwardMessages({ noAuthors, noCaptions, isCurrentUserPremium, + wasDrafted, }: { fromChat: ApiChat; toChat: ApiChat; @@ -1296,6 +1300,7 @@ export async function forwardMessages({ noAuthors?: boolean; noCaptions?: boolean; isCurrentUserPremium?: boolean; + wasDrafted?: boolean; }) { const messageIds = messages.map(({ id }) => id); const randomIds = messages.map(generateRandomBigInt); @@ -1318,6 +1323,7 @@ export async function forwardMessages({ id: localMessage.id, chatId: toChat.id, message: localMessage, + wasDrafted, }); }); diff --git a/src/api/types/updates.ts b/src/api/types/updates.ts index b86dea65e..5ba9589c8 100644 --- a/src/api/types/updates.ts +++ b/src/api/types/updates.ts @@ -191,6 +191,7 @@ export type ApiUpdateNewScheduledMessage = { chatId: string; id: number; message: ApiMessage; + wasDrafted?: boolean; }; export type ApiUpdateNewMessage = { @@ -199,6 +200,7 @@ export type ApiUpdateNewMessage = { id: number; message: Partial; shouldForceReply?: boolean; + wasDrafted?: boolean; }; export type ApiUpdateMessage = { diff --git a/src/components/common/LastMessageMeta.tsx b/src/components/common/LastMessageMeta.tsx index 7283f8332..16fd0c6ef 100644 --- a/src/components/common/LastMessageMeta.tsx +++ b/src/components/common/LastMessageMeta.tsx @@ -14,16 +14,21 @@ import './LastMessageMeta.scss'; type OwnProps = { message: ApiMessage; outgoingStatus?: ApiMessageOutgoingStatus; + draftDate?: number; }; -const LastMessageMeta: FC = ({ message, outgoingStatus }) => { +const LastMessageMeta: FC = ({ message, outgoingStatus, draftDate }) => { const lang = useLang(); + + const shouldUseDraft = draftDate && draftDate > message.date; return (
- {outgoingStatus && ( + {outgoingStatus && !shouldUseDraft && ( )} - {formatPastTimeShort(lang, message.date * 1000)} + + {formatPastTimeShort(lang, (shouldUseDraft ? draftDate : message.date) * 1000)} +
); }; diff --git a/src/components/common/embedded/EmbeddedMessage.scss b/src/components/common/embedded/EmbeddedMessage.scss index 373fd7ad1..b83ff3385 100644 --- a/src/components/common/embedded/EmbeddedMessage.scss +++ b/src/components/common/embedded/EmbeddedMessage.scss @@ -30,10 +30,6 @@ background-color: var(--color-reply-active); box-shadow: 0 1px 2px var(--color-default-shadow); - .embedded-thumb { - margin-inline-start: 0.5rem; - } - &:dir(rtl) { padding: 0.5rem; } diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index 19dbe5d2b..782585a09 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -293,6 +293,7 @@ const Chat: FC = ({ )} diff --git a/src/components/left/main/hooks/useChatListEntry.tsx b/src/components/left/main/hooks/useChatListEntry.tsx index c97fdb8ff..5caf68235 100644 --- a/src/components/left/main/hooks/useChatListEntry.tsx +++ b/src/components/left/main/hooks/useChatListEntry.tsx @@ -105,8 +105,11 @@ export default function useChatListEntry({ } const isDraftReplyToTopic = draft && draft.replyInfo?.replyToMsgId === lastMessageTopic?.id; + const isEmptyLocalReply = draft?.replyInfo && !draft.text && draft.isLocal; - if (draft && (!chat?.isForum || (isTopic && !isDraftReplyToTopic))) { + const canDisplayDraft = !chat?.isForum && draft && !isEmptyLocalReply && (!isTopic || !isDraftReplyToTopic); + + if (canDisplayDraft) { return (

{lang('Draft')} diff --git a/src/components/middle/composer/ComposerEmbeddedMessage.tsx b/src/components/middle/composer/ComposerEmbeddedMessage.tsx index ff4c3fae1..1eaef8ae2 100644 --- a/src/components/middle/composer/ComposerEmbeddedMessage.tsx +++ b/src/components/middle/composer/ComposerEmbeddedMessage.tsx @@ -53,6 +53,7 @@ type StateProps = { forwardsHaveCaptions?: boolean; isCurrentUserPremium?: boolean; isContextMenuDisabled?: boolean; + isReplyToDiscussion?: boolean; }; type OwnProps = { @@ -75,6 +76,7 @@ const ComposerEmbeddedMessage: FC = ({ shouldForceShowEditing, isCurrentUserPremium, isContextMenuDisabled, + isReplyToDiscussion, onClear, }) => { const { @@ -105,7 +107,7 @@ const ComposerEmbeddedMessage: FC = ({ const { shouldRender, transitionClassNames, } = useShowTransition( - canAnimate && isShown && !isReplyToTopicStart, + canAnimate && isShown && !isReplyToTopicStart && !isReplyToDiscussion, undefined, !shouldAnimate, undefined, @@ -167,8 +169,10 @@ const ComposerEmbeddedMessage: FC = ({ getPeerColorClass(sender), ); + const isShowingReply = replyInfo && !shouldForceShowEditing; + const leftIcon = useMemo(() => { - if (replyInfo && !shouldForceShowEditing) { + if (isShowingReply) { return 'icon-reply'; } if (editingId) { @@ -179,7 +183,7 @@ const ComposerEmbeddedMessage: FC = ({ } return undefined; - }, [editingId, isForwarding, replyInfo, shouldForceShowEditing]); + }, [editingId, isForwarding, isShowingReply]); const customText = forwardedMessagesCount && forwardedMessagesCount > 1 ? lang('ForwardedMessageCount', forwardedMessagesCount) @@ -214,7 +218,8 @@ const ComposerEmbeddedMessage: FC = ({ message={strippedMessage} sender={!noAuthors ? sender : undefined} customText={customText} - title={editingId ? lang('EditMessage') : noAuthors ? lang('HiddenSendersNameDescription') : undefined} + title={(editingId && !isShowingReply) ? lang('EditMessage') + : noAuthors ? lang('HiddenSendersNameDescription') : undefined} onClick={handleMessageClick} />