feat: pass yarn ready

pull/2757/head
William Grant 2 years ago
parent aa3855e49f
commit 92ed15c6c4

@ -47,6 +47,38 @@ const StyledText = styled(Flex)`
}
`;
function checkHasAttachments(attachments: Array<any> | undefined) {
const hasAttachments = attachments && attachments.length > 0 && attachments[0];
// NOTE could be a video as well which will load a thumbnail
const firstImageLikeAttachment =
hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail
? attachments[0]
: undefined;
return { hasAttachments, firstImageLikeAttachment };
}
function renderSubtitleText(
quoteText: string | undefined,
hasAudioAttachment: boolean,
isGenericFile: boolean,
isVideo: boolean,
isImage: boolean
): string | null {
return quoteText && quoteText !== ''
? quoteText
: hasAudioAttachment
? window.i18n('audio')
: isGenericFile
? window.i18n('document')
: isVideo
? window.i18n('video')
: isImage
? window.i18n('image')
: null;
}
export const SessionQuotedMessageComposition = () => {
const dispatch = useDispatch();
const quotedMessageProps = useSelector(getQuotedMessage);
@ -66,32 +98,25 @@ export const SessionQuotedMessageComposition = () => {
const contact = findAndFormatContact(author);
const authorName = contact?.profileName || contact?.name || author || window.i18n('unknown');
const hasAttachments = attachments && attachments.length > 0 && attachments[0];
const firstImageAttachment =
hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail
? attachments[0]
: undefined;
const { hasAttachments, firstImageLikeAttachment } = checkHasAttachments(attachments);
const isImage = Boolean(
firstImageAttachment && GoogleChrome.isImageTypeSupported(firstImageAttachment.contentType)
firstImageLikeAttachment &&
GoogleChrome.isImageTypeSupported(firstImageLikeAttachment.contentType)
);
const isVideo = Boolean(
firstImageAttachment && GoogleChrome.isVideoTypeSupported(firstImageAttachment.contentType)
firstImageLikeAttachment &&
GoogleChrome.isVideoTypeSupported(firstImageLikeAttachment.contentType)
);
const hasAudioAttachment = Boolean(hasAttachments && isAudio(attachments));
const isGenericFile = !hasAudioAttachment && !isVideo && !isImage;
const subtitleText =
quoteText !== ''
? quoteText
: hasAudioAttachment
? window.i18n('audio')
: isGenericFile
? window.i18n('document')
: isVideo
? window.i18n('video')
: isImage
? window.i18n('image')
: null;
const subtitleText = renderSubtitleText(
quoteText,
hasAudioAttachment,
isGenericFile,
isVideo,
isImage
);
return (
<QuotedMessageComposition
@ -110,13 +135,13 @@ export const SessionQuotedMessageComposition = () => {
>
{hasAttachments && (
<StyledImage>
{firstImageAttachment ? (
{firstImageLikeAttachment ? (
<Image
alt={getAlt(firstImageAttachment)}
attachment={firstImageAttachment}
alt={getAlt(firstImageLikeAttachment)}
attachment={firstImageLikeAttachment}
height={100}
width={100}
url={getAbsoluteAttachmentPath((firstImageAttachment as any).thumbnail.path)}
url={getAbsoluteAttachmentPath((firstImageLikeAttachment as any).thumbnail.path)}
softCorners={true}
/>
) : hasAudioAttachment ? (

@ -1,8 +1,9 @@
import React from 'react';
import React, { MouseEvent } from 'react';
import styled from 'styled-components';
// tslint:disable: react-unused-props-and-state
interface Props {
onClick: () => void;
onClick: (e: MouseEvent<HTMLDivElement>) => void;
}
const StyledStagedPlaceholderAttachment = styled.div`
@ -21,7 +22,7 @@ const StyledStagedPlaceholderAttachment = styled.div`
}
`;
export function StagedPlaceholderAttachment(props: Props) {
export const StagedPlaceholderAttachment = (props: Props) => {
const { onClick } = props;
return (
@ -29,4 +30,4 @@ export function StagedPlaceholderAttachment(props: Props) {
<div className="module-staged-placeholder-attachment__plus-icon" />
</StyledStagedPlaceholderAttachment>
);
}
};

@ -1,4 +1,4 @@
import React, { useState, MouseEvent } from 'react';
import React, { MouseEvent, useState } from 'react';
import * as MIME from '../../../../../types/MIME';

@ -1,4 +1,4 @@
import React = require('react');
import React from 'react';
import { ContactName } from '../../../ContactName';
import { PubKey } from '../../../../../session/types';
import styled from 'styled-components';

@ -6,7 +6,7 @@ import { MIME } from '../../../../../types';
import { isEmpty, noop } from 'lodash';
import { QuoteImage } from './QuoteImage';
import styled from 'styled-components';
import { SessionIconType, icons } from '../../../../icon';
import { icons, SessionIconType } from '../../../../icon';
function getObjectUrl(thumbnail: Attachment | undefined): string | undefined {
if (thumbnail && thumbnail.objectUrl) {

@ -82,8 +82,8 @@ export const QuoteImage = (props: {
{showPlayButton && (
<StyledPlayButton>
<div>
<svg viewBox={icons['play'].viewBox}>
<path d={icons['play'].path} />
<svg viewBox={icons.play.viewBox}>
<path d={icons.play.path} />
</svg>
</div>
</StyledPlayButton>

@ -452,8 +452,8 @@ async function filterAlreadyFetchedOpengroupMessage(
/**
* Fetch all messages that match the sender pubkey and sent_at timestamp
* @param {Object[]} propsList An array of objects containing a source (the sender id) and timestamp of the message - not to be confused with the serverTimestamp. This is equivalent to sent_at
* @returns
* @param propsList An array of objects containing a source (the sender id) and timestamp of the message - not to be confused with the serverTimestamp. This is equivalent to sent_at
* @returns the fetched messageModels
*/
async function getMessagesBySenderAndSentAt(
propsList: Array<{

@ -1073,8 +1073,8 @@ function getMessagesBySenderAndSentAt(
const db = assertGlobalInstance();
const rows = [];
for (let i = 0; i < propsList.length; i++) {
const { source, timestamp } = propsList[i];
for (const msgProps of propsList) {
const { source, timestamp } = msgProps;
const _rows = db
.prepare(

@ -347,9 +347,9 @@ export type MentionsMembersType = Array<{
/**
* Fetches the messages for a conversation to put into redux.
* @param {string} conversationKey - the id of the conversation
* @param {string} messageId - the id of the message in view so we can fetch the messages around it
* @returns
* @param conversationKey - the id of the conversation
* @param messageId - the id of the message in view so we can fetch the messages around it
* @returns the fetched models for messages and quoted messages
*/
async function getMessages({
conversationKey,
@ -408,7 +408,6 @@ async function getMessages({
}
}
// window.log.debug(`WIP: duck quotesProps`, quotesProps);
return { messagesProps, quotesProps };
}
@ -575,15 +574,11 @@ function handleMessageExpiredOrDeleted(
if (timestamp && sender) {
const message2Delete = editedQuotes[`${timestamp}-${sender}`];
window.log.debug(
`WIP: deleting quote {${timestamp}-${sender}} ${JSON.stringify(message2Delete)}`
);
window.log.debug(
`WIP: editedQuotes count before delete ${Object.keys(editedQuotes).length}`
`Deleting quote {${timestamp}-${sender}} ${JSON.stringify(message2Delete)}`
);
// tslint:disable-next-line: no-dynamic-delete
delete editedQuotes[`${timestamp}-${sender}`];
window.log.debug(
`WIP: editedQuotes count after delete ${Object.keys(editedQuotes).length}`
);
}
// we cannot edit the array directly, so slice the first part, and slice the second part,

@ -980,6 +980,7 @@ export const getMessageLinkPreviewProps = createSelector(getMessagePropsByMessag
return msgProps;
});
// tslint:disable: cyclomatic-complexity
export const getMessageQuoteProps = createSelector(
getConversationQuotes,
getMessagePropsByMessageId,
@ -1050,6 +1051,7 @@ export const getMessageQuoteProps = createSelector(
return { direction, quote };
}
);
// tslint:enable: cyclomatic-complexity
export const getMessageStatusProps = createSelector(getMessagePropsByMessageId, (props):
| MessageStatusSelectorProps

Loading…
Cancel
Save