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 = () => { export const SessionQuotedMessageComposition = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const quotedMessageProps = useSelector(getQuotedMessage); const quotedMessageProps = useSelector(getQuotedMessage);
@ -66,32 +98,25 @@ export const SessionQuotedMessageComposition = () => {
const contact = findAndFormatContact(author); const contact = findAndFormatContact(author);
const authorName = contact?.profileName || contact?.name || author || window.i18n('unknown'); const authorName = contact?.profileName || contact?.name || author || window.i18n('unknown');
const hasAttachments = attachments && attachments.length > 0 && attachments[0]; const { hasAttachments, firstImageLikeAttachment } = checkHasAttachments(attachments);
const firstImageAttachment =
hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail
? attachments[0]
: undefined;
const isImage = Boolean( const isImage = Boolean(
firstImageAttachment && GoogleChrome.isImageTypeSupported(firstImageAttachment.contentType) firstImageLikeAttachment &&
GoogleChrome.isImageTypeSupported(firstImageLikeAttachment.contentType)
); );
const isVideo = Boolean( const isVideo = Boolean(
firstImageAttachment && GoogleChrome.isVideoTypeSupported(firstImageAttachment.contentType) firstImageLikeAttachment &&
GoogleChrome.isVideoTypeSupported(firstImageLikeAttachment.contentType)
); );
const hasAudioAttachment = Boolean(hasAttachments && isAudio(attachments)); const hasAudioAttachment = Boolean(hasAttachments && isAudio(attachments));
const isGenericFile = !hasAudioAttachment && !isVideo && !isImage; const isGenericFile = !hasAudioAttachment && !isVideo && !isImage;
const subtitleText = const subtitleText = renderSubtitleText(
quoteText !== '' quoteText,
? quoteText hasAudioAttachment,
: hasAudioAttachment isGenericFile,
? window.i18n('audio') isVideo,
: isGenericFile isImage
? window.i18n('document') );
: isVideo
? window.i18n('video')
: isImage
? window.i18n('image')
: null;
return ( return (
<QuotedMessageComposition <QuotedMessageComposition
@ -110,13 +135,13 @@ export const SessionQuotedMessageComposition = () => {
> >
{hasAttachments && ( {hasAttachments && (
<StyledImage> <StyledImage>
{firstImageAttachment ? ( {firstImageLikeAttachment ? (
<Image <Image
alt={getAlt(firstImageAttachment)} alt={getAlt(firstImageLikeAttachment)}
attachment={firstImageAttachment} attachment={firstImageLikeAttachment}
height={100} height={100}
width={100} width={100}
url={getAbsoluteAttachmentPath((firstImageAttachment as any).thumbnail.path)} url={getAbsoluteAttachmentPath((firstImageLikeAttachment as any).thumbnail.path)}
softCorners={true} softCorners={true}
/> />
) : hasAudioAttachment ? ( ) : hasAudioAttachment ? (

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

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

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

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

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

@ -452,8 +452,8 @@ async function filterAlreadyFetchedOpengroupMessage(
/** /**
* Fetch all messages that match the sender pubkey and sent_at timestamp * 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 * @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 * @returns the fetched messageModels
*/ */
async function getMessagesBySenderAndSentAt( async function getMessagesBySenderAndSentAt(
propsList: Array<{ propsList: Array<{

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

@ -347,9 +347,9 @@ export type MentionsMembersType = Array<{
/** /**
* Fetches the messages for a conversation to put into redux. * Fetches the messages for a conversation to put into redux.
* @param {string} conversationKey - the id of the conversation * @param conversationKey - the id of the conversation
* @param {string} messageId - the id of the message in view so we can fetch the messages around it * @param messageId - the id of the message in view so we can fetch the messages around it
* @returns * @returns the fetched models for messages and quoted messages
*/ */
async function getMessages({ async function getMessages({
conversationKey, conversationKey,
@ -408,7 +408,6 @@ async function getMessages({
} }
} }
// window.log.debug(`WIP: duck quotesProps`, quotesProps);
return { messagesProps, quotesProps }; return { messagesProps, quotesProps };
} }
@ -575,15 +574,11 @@ function handleMessageExpiredOrDeleted(
if (timestamp && sender) { if (timestamp && sender) {
const message2Delete = editedQuotes[`${timestamp}-${sender}`]; const message2Delete = editedQuotes[`${timestamp}-${sender}`];
window.log.debug( window.log.debug(
`WIP: deleting quote {${timestamp}-${sender}} ${JSON.stringify(message2Delete)}` `Deleting quote {${timestamp}-${sender}} ${JSON.stringify(message2Delete)}`
);
window.log.debug(
`WIP: editedQuotes count before delete ${Object.keys(editedQuotes).length}`
); );
// tslint:disable-next-line: no-dynamic-delete
delete editedQuotes[`${timestamp}-${sender}`]; 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, // 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; return msgProps;
}); });
// tslint:disable: cyclomatic-complexity
export const getMessageQuoteProps = createSelector( export const getMessageQuoteProps = createSelector(
getConversationQuotes, getConversationQuotes,
getMessagePropsByMessageId, getMessagePropsByMessageId,
@ -1050,6 +1051,7 @@ export const getMessageQuoteProps = createSelector(
return { direction, quote }; return { direction, quote };
} }
); );
// tslint:enable: cyclomatic-complexity
export const getMessageStatusProps = createSelector(getMessagePropsByMessageId, (props): export const getMessageStatusProps = createSelector(getMessagePropsByMessageId, (props):
| MessageStatusSelectorProps | MessageStatusSelectorProps

Loading…
Cancel
Save