Fix image send without description
This commit is contained in:
parent
57f7dc1b16
commit
6afb6f9ac3
1 changed files with 14 additions and 3 deletions
|
@ -13,6 +13,7 @@ import type { LocalizerType, ThemeType } from '../types/Util';
|
||||||
import type { ErrorDialogAudioRecorderType } from '../types/AudioRecorder';
|
import type { ErrorDialogAudioRecorderType } from '../types/AudioRecorder';
|
||||||
import { RecordingState } from '../types/AudioRecorder';
|
import { RecordingState } from '../types/AudioRecorder';
|
||||||
import type { imageToBlurHash } from '../util/imageToBlurHash';
|
import type { imageToBlurHash } from '../util/imageToBlurHash';
|
||||||
|
import { dropNull } from '../util/dropNull';
|
||||||
import { Spinner } from './Spinner';
|
import { Spinner } from './Spinner';
|
||||||
import type {
|
import type {
|
||||||
Props as EmojiButtonProps,
|
Props as EmojiButtonProps,
|
||||||
|
@ -358,13 +359,23 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
const draftEditMessageBody = draftEditMessage?.body;
|
const draftEditMessageBody = draftEditMessage?.body;
|
||||||
const editedMessageId = draftEditMessage?.targetMessageId;
|
const editedMessageId = draftEditMessage?.targetMessageId;
|
||||||
|
|
||||||
|
const canSend =
|
||||||
|
// Text or link preview edited
|
||||||
|
dirty ||
|
||||||
|
// Quote of edited message changed
|
||||||
|
(draftEditMessage != null &&
|
||||||
|
dropNull(draftEditMessage.quote?.messageId) !==
|
||||||
|
dropNull(quotedMessageId)) ||
|
||||||
|
// Not edit message, but has attachments
|
||||||
|
(draftEditMessage == null && draftAttachments.length !== 0);
|
||||||
|
|
||||||
const handleSubmit = useCallback(
|
const handleSubmit = useCallback(
|
||||||
(
|
(
|
||||||
message: string,
|
message: string,
|
||||||
bodyRanges: DraftBodyRanges,
|
bodyRanges: DraftBodyRanges,
|
||||||
timestamp: number
|
timestamp: number
|
||||||
): boolean => {
|
): boolean => {
|
||||||
if (!dirty) {
|
if (!canSend) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +404,7 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
conversationId,
|
conversationId,
|
||||||
dirty,
|
canSend,
|
||||||
draftAttachments,
|
draftAttachments,
|
||||||
editedMessageId,
|
editedMessageId,
|
||||||
quotedMessageSentAt,
|
quotedMessageSentAt,
|
||||||
|
@ -603,7 +614,7 @@ export const CompositionArea = memo(function CompositionArea({
|
||||||
<button
|
<button
|
||||||
aria-label={i18n('icu:CompositionArea__edit-action--send')}
|
aria-label={i18n('icu:CompositionArea__edit-action--send')}
|
||||||
className="CompositionArea__edit-button CompositionArea__edit-button--accept"
|
className="CompositionArea__edit-button CompositionArea__edit-button--accept"
|
||||||
disabled={!dirty}
|
disabled={!canSend}
|
||||||
onClick={() => inputApiRef.current?.submit()}
|
onClick={() => inputApiRef.current?.submit()}
|
||||||
type="button"
|
type="button"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue