Allow stage and send of video, even if we can't get screenshot

This commit is contained in:
Scott Nonnenberg 2021-11-15 13:54:33 -08:00 committed by GitHub
parent 117cb074c7
commit a024ee4b96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 224 additions and 143 deletions

View file

@ -4,7 +4,7 @@
import type { ThunkAction } from 'redux-thunk';
import * as log from '../../logging/log';
import type { AttachmentType } from '../../types/Attachment';
import type { InMemoryAttachmentDraftType } from '../../types/Attachment';
import { SignalService as Proto } from '../../protobuf';
import type { StateType as RootStateType } from '../reducer';
import { fileToBytes } from '../../util/fileToBytes';
@ -129,7 +129,7 @@ function completeRecordingAction(): CompleteRecordingAction {
function completeRecording(
conversationId: string,
onSendAudioRecording?: (rec: AttachmentType) => unknown
onSendAudioRecording?: (rec: InMemoryAttachmentDraftType) => unknown
): ThunkAction<
void,
RootStateType,
@ -158,7 +158,8 @@ function completeRecording(
}
const data = await fileToBytes(blob);
const voiceNoteAttachment = {
const voiceNoteAttachment: InMemoryAttachmentDraftType = {
pending: false,
contentType: stringToMIMEType(blob.type),
data,
size: data.byteLength,

View file

@ -6,7 +6,10 @@ import type { ThunkAction } from 'redux-thunk';
import * as log from '../../logging/log';
import type { NoopActionType } from './noop';
import type { StateType as RootStateType } from '../reducer';
import type { AttachmentType } from '../../types/Attachment';
import type {
AttachmentDraftType,
InMemoryAttachmentDraftType,
} from '../../types/Attachment';
import type { MessageAttributesType } from '../../model-types.d';
import type { LinkPreviewWithDomain } from '../../types/LinkPreview';
import { assignWithNoUnnecessaryAllocation } from '../../util/assignWithNoUnnecessaryAllocation';
@ -15,14 +18,14 @@ import { REMOVE_PREVIEW as REMOVE_LINK_PREVIEW } from './linkPreviews';
import { writeDraftAttachment } from '../../util/writeDraftAttachment';
import { deleteDraftAttachment } from '../../util/deleteDraftAttachment';
import { replaceIndex } from '../../util/replaceIndex';
import { resolveAttachmentOnDisk } from '../../util/resolveAttachmentOnDisk';
import { resolveDraftAttachmentOnDisk } from '../../util/resolveDraftAttachmentOnDisk';
import type { HandleAttachmentsProcessingArgsType } from '../../util/handleAttachmentsProcessing';
import { handleAttachmentsProcessing } from '../../util/handleAttachmentsProcessing';
// State
export type ComposerStateType = {
attachments: ReadonlyArray<AttachmentType>;
attachments: ReadonlyArray<AttachmentDraftType>;
linkPreviewLoading: boolean;
linkPreviewResult?: LinkPreviewWithDomain;
quotedMessage?: Pick<MessageAttributesType, 'conversationId' | 'quote'>;
@ -40,12 +43,12 @@ const SET_QUOTED_MESSAGE = 'composer/SET_QUOTED_MESSAGE';
type AddPendingAttachmentActionType = {
type: typeof ADD_PENDING_ATTACHMENT;
payload: AttachmentType;
payload: AttachmentDraftType;
};
type ReplaceAttachmentsActionType = {
type: typeof REPLACE_ATTACHMENTS;
payload: ReadonlyArray<AttachmentType>;
payload: ReadonlyArray<AttachmentDraftType>;
};
type ResetComposerActionType = {
@ -99,14 +102,14 @@ export const actions = {
// next in-memory store.
function getAttachmentsFromConversationModel(
conversationId: string
): Array<AttachmentType> {
): Array<AttachmentDraftType> {
const conversation = window.ConversationController.get(conversationId);
return conversation?.get('draftAttachments') || [];
}
function addAttachment(
conversationId: string,
attachment: AttachmentType
attachment: InMemoryAttachmentDraftType
): ThunkAction<void, RootStateType, unknown, ReplaceAttachmentsActionType> {
return async (dispatch, getState) => {
// We do async operations first so multiple in-process addAttachments don't stomp on
@ -161,7 +164,7 @@ function addAttachment(
function addPendingAttachment(
conversationId: string,
pendingAttachment: AttachmentType
pendingAttachment: AttachmentDraftType
): ThunkAction<void, RootStateType, unknown, ReplaceAttachmentsActionType> {
return (dispatch, getState) => {
const isSelectedConversation =
@ -240,7 +243,7 @@ function removeAttachment(
function replaceAttachments(
conversationId: string,
attachments: ReadonlyArray<AttachmentType>
attachments: ReadonlyArray<AttachmentDraftType>
): ThunkAction<void, RootStateType, unknown, ReplaceAttachmentsActionType> {
return (dispatch, getState) => {
// If the call came from a conversation we are no longer in we do not
@ -251,7 +254,7 @@ function replaceAttachments(
dispatch({
type: REPLACE_ATTACHMENTS,
payload: attachments.map(resolveAttachmentOnDisk),
payload: attachments.map(resolveDraftAttachmentOnDisk),
});
};
}

View file

@ -13,15 +13,15 @@ import { getLinkPreview } from '../selectors/linkPreviews';
import { getIntl, getTheme } from '../selectors/user';
import { getEmojiSkinTone } from '../selectors/items';
import { selectRecentEmojis } from '../selectors/emojis';
import type { AttachmentType } from '../../types/Attachment';
import type { AttachmentDraftType } from '../../types/Attachment';
export type SmartForwardMessageModalProps = {
attachments?: Array<AttachmentType>;
attachments?: Array<AttachmentDraftType>;
conversationId: string;
doForwardMessage: (
selectedContacts: Array<string>,
messageBody?: string,
attachments?: Array<AttachmentType>,
attachments?: Array<AttachmentDraftType>,
linkPreview?: LinkPreviewType
) => void;
isSticker: boolean;