Allow stage and send of video, even if we can't get screenshot
This commit is contained in:
parent
117cb074c7
commit
a024ee4b96
21 changed files with 224 additions and 143 deletions
|
@ -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),
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue