Do not attach files while voice recording in progress

This commit is contained in:
Josh Perez 2022-02-11 15:18:04 -05:00 committed by GitHub
parent 8c85a9d37f
commit 138580fedb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View file

@ -11,10 +11,8 @@ import type {
LocalizerType, LocalizerType,
ThemeType, ThemeType,
} from '../types/Util'; } from '../types/Util';
import type { import type { ErrorDialogAudioRecorderType } from '../state/ducks/audioRecorder';
ErrorDialogAudioRecorderType, import { RecordingState } from '../state/ducks/audioRecorder';
RecordingState,
} from '../state/ducks/audioRecorder';
import type { HandleAttachmentsProcessingArgsType } from '../util/handleAttachmentsProcessing'; import type { HandleAttachmentsProcessingArgsType } from '../util/handleAttachmentsProcessing';
import { Spinner } from './Spinner'; import { Spinner } from './Spinner';
import type { Props as EmojiButtonProps } from './emoji/EmojiButton'; import type { Props as EmojiButtonProps } from './emoji/EmojiButton';
@ -399,16 +397,18 @@ export const CompositionArea = ({
/> />
) : null; ) : null;
const attButton = linkPreviewResult ? undefined : ( const isRecording = recordingState === RecordingState.Recording;
<div className="CompositionArea__button-cell"> const attButton =
<button linkPreviewResult || isRecording ? undefined : (
type="button" <div className="CompositionArea__button-cell">
className="CompositionArea__attach-file" <button
onClick={launchAttachmentPicker} type="button"
aria-label={i18n('CompositionArea--attach-file')} className="CompositionArea__attach-file"
/> onClick={launchAttachmentPicker}
</div> aria-label={i18n('CompositionArea--attach-file')}
); />
</div>
);
const sendButtonFragment = ( const sendButtonFragment = (
<div <div

View file

@ -110,6 +110,7 @@ import { resolveAttachmentDraftData } from '../util/resolveAttachmentDraftData';
import { showToast } from '../util/showToast'; import { showToast } from '../util/showToast';
import { viewSyncJobQueue } from '../jobs/viewSyncJobQueue'; import { viewSyncJobQueue } from '../jobs/viewSyncJobQueue';
import { viewedReceiptsJobQueue } from '../jobs/viewedReceiptsJobQueue'; import { viewedReceiptsJobQueue } from '../jobs/viewedReceiptsJobQueue';
import { RecordingState } from '../state/ducks/audioRecorder';
type AttachmentOptions = { type AttachmentOptions = {
messageId: string; messageId: string;
@ -964,7 +965,12 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
// TODO DESKTOP-2426 // TODO DESKTOP-2426
async processAttachments(files: Array<File>): Promise<void> { async processAttachments(files: Array<File>): Promise<void> {
if (this.preview) { const state = window.reduxStore.getState();
const isRecording =
state.audioRecorder.recordingState === RecordingState.Recording;
if (this.preview || isRecording) {
return; return;
} }