@ -15,7 +15,7 @@ import { SessionMessagesListContainer } from './SessionMessagesListContainer';
import { LightboxGallery , MediaItemType } from '../../LightboxGallery' ;
import { AttachmentType , AttachmentTypeWithPath , save } from '../../../types/Attachment' ;
import { ToastUtils } from '../../../session/utils' ;
import { ToastUtils , UserUtils } from '../../../session/utils' ;
import * as MIME from '../../../types/MIME' ;
import { SessionFileDropzone } from './SessionFileDropzone' ;
import {
@ -37,12 +37,14 @@ import {
isFirstUnreadMessageIdAbove ,
} from '../../../state/selectors/conversations' ;
import { SessionButtonColor } from '../SessionButton' ;
import { updateConfirmModal } from '../../../state/ducks/modalDialog' ;
interface State {
showRecordingView : boolean ;
stagedAttachments : Array < StagedAttachmentType > ;
isDraggingFile : boolean ;
}
export interface LightBoxOptions {
media : Array < MediaItemType > ;
attachment : AttachmentTypeWithPath ;
@ -211,12 +213,35 @@ export class SessionConversation extends React.Component<Props, State> {
if ( ! conversationModel ) {
return ;
}
void conversationModel . sendMessage ( body , attachments , quote , preview , groupInvitation ) ;
if ( this . messageContainerRef . current ) {
// force scrolling to bottom on message sent
// this will mark all messages as read, and reset the conversation unreadCount
( this . messageContainerRef
. current as any ) . scrollTop = this . messageContainerRef . current ? . scrollHeight ;
const sendAndScroll = ( ) = > {
void conversationModel . sendMessage ( body , attachments , quote , preview , groupInvitation ) ;
if ( this . messageContainerRef . current ) {
( this . messageContainerRef
. current as any ) . scrollTop = this . messageContainerRef . current ? . scrollHeight ;
}
} ;
// const recoveryPhrase = window.textsecure.storage.get('mnemonic');
const recoveryPhrase = UserUtils . getCurrentRecoveryPhrase ( ) ;
// string replace to fix case where pasted text contains invis characters causing false negatives
if ( body . replace ( /\s/g , '' ) . includes ( recoveryPhrase . replace ( /\s/g , '' ) ) ) {
window . inboxStore ? . dispatch (
updateConfirmModal ( {
title : window.i18n ( 'sendRecoveryPhraseTitle' ) ,
message : window.i18n ( 'sendRecoveryPhraseMessage' ) ,
okTheme : SessionButtonColor.Danger ,
onClickOk : ( ) = > {
sendAndScroll ( ) ;
} ,
onClickClose : ( ) = > {
window . inboxStore ? . dispatch ( updateConfirmModal ( null ) ) ;
} ,
} )
) ;
} else {
sendAndScroll ( ) ;
}
window . inboxStore ? . dispatch ( quoteMessage ( undefined ) ) ;