From 061cb38300aca69c0603a54d5cbcabcce193c019 Mon Sep 17 00:00:00 2001 From: Warrick Corfe-Tan Date: Mon, 21 Jun 2021 13:36:28 +1000 Subject: [PATCH] Linting and formatting changes applied. --- ts/components/conversation/Message.tsx | 47 ++++++++++++---------- ts/components/session/icon/SessionIcon.tsx | 7 +++- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index c7a15395b..aa74447ec 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -1,4 +1,4 @@ -import React, { createRef } from 'react'; +import React, { createRef, useEffect } from 'react'; import classNames from 'classnames'; import { Avatar, AvatarSize } from '../Avatar'; @@ -13,19 +13,22 @@ import { Quote } from './Quote'; import H5AudioPlayer from 'react-h5-audio-player'; // import 'react-h5-audio-player/lib/styles.css'; -const AudioPlayerWithEncryptedFile = (props: { src: string; contentType: string, playbackSpeed: number }) => { +const AudioPlayerWithEncryptedFile = (props: { + src: string; + contentType: string; + playbackSpeed: number; +}) => { const theme = useTheme(); const { urlToLoad } = useEncryptedFileFetch(props.src, props.contentType); const { playbackSpeed } = props; const player = createRef(); useEffect(() => { - // updates playback speed to value selected in context menu if (player.current?.audio.current?.playbackRate) { player.current.audio.current.playbackRate = playbackSpeed; } - }, [playbackSpeed]) + }, [playbackSpeed]); return ( { expiring: false, expired: false, imageBroken: false, - playbackSpeed: 1 + playbackSpeed: 1, }; this.ctxMenuID = `ctx-menu-message-${uuid()}`; } @@ -191,18 +193,6 @@ class MessageInner extends React.PureComponent { }); } - - /** - * Doubles / halves the playback speed based on the current playback speed. - */ - private updatePlaybackSpeed() { - console.log('updating playback speed'); - this.setState({ - ...this.state, - playbackSpeed: this.state.playbackSpeed === 1 ? 2 : 1 - }); - } - // tslint:disable-next-line max-func-body-length cyclomatic-complexity public renderAttachment() { const { @@ -618,7 +608,6 @@ class MessageInner extends React.PureComponent { const selectMessageText = window.i18n('selectMessage'); const deleteMessageText = window.i18n('deleteMessage'); - return ( { ) : null} - {window.i18n('playAtCustomSpeed', this.state.playbackSpeed === 1 ? 2 : 1)} + {isAudio(attachments) ? ( + + {window.i18n('playAtCustomSpeed', this.state.playbackSpeed === 1 ? 2 : 1)} + + ) : null} {window.i18n('copyMessage')} {window.i18n('replyToMessage')} {window.i18n('moreInformation')} @@ -731,8 +724,8 @@ class MessageInner extends React.PureComponent { return Boolean( displayImage && - ((isImage(attachments) && hasImage(attachments)) || - (isVideo(attachments) && hasVideoScreenshot(attachments))) + ((isImage(attachments) && hasImage(attachments)) || + (isVideo(attachments) && hasVideoScreenshot(attachments))) ); } @@ -879,6 +872,16 @@ class MessageInner extends React.PureComponent { ); } + /** + * Doubles / halves the playback speed based on the current playback speed. + */ + private updatePlaybackSpeed() { + this.setState({ + ...this.state, + playbackSpeed: this.state.playbackSpeed === 1 ? 2 : 1, + }); + } + private handleContextMenu(e: any) { e.preventDefault(); e.stopPropagation(); diff --git a/ts/components/session/icon/SessionIcon.tsx b/ts/components/session/icon/SessionIcon.tsx index e506456e1..0abe25f84 100644 --- a/ts/components/session/icon/SessionIcon.tsx +++ b/ts/components/session/icon/SessionIcon.tsx @@ -66,7 +66,6 @@ const glow = (color: string, glowDuration: number, glowStartDelay: number) => { //increase shadow intensity by 3 const dropShadow = `${dropShadowType.repeat(2)};`; - // TODO: Decrease dropshadow for last frame // creating keyframe for sequential animations let kf = ''; for (let i = 0; i <= glowDuration; i++) { @@ -94,7 +93,11 @@ const animation = (props: any) => { `; } else if (props.glowDuration !== undefined && props.glowStartDelay !== undefined) { return css` - ${glow(props.iconColor, props.glowDuration, props.glowStartDelay)} ${props.glowDuration}s ease-in infinite; + ${glow( + props.iconColor, + props.glowDuration, + props.glowStartDelay + )} ${props.glowDuration}s ease-in infinite; `; } else { return;