import React from 'react'; import { ConversationHeader } from '../conversation/ConversationHeader'; import { SessionCompositionBox } from './SessionCompositionBox'; import { SessionProgress } from './SessionProgress' import { Message } from '../conversation/Message'; interface Props { getHeaderProps: any; conversationKey: any; } interface State { sendingProgess: number; prevSendingProgess: number; loadingMessages: boolean; messages: any; } export class SessionConversation extends React.Component { constructor(props: any) { super(props); this.state = { sendingProgess: 0, prevSendingProgess: 0, loadingMessages: false, messages: {}, }; } async componentWillMount() { const { conversationKey } = this.props; this.setState({ messages: await window.getMessagesByKey(conversationKey) }) } render() { // const headerProps = this.props.getHeaderProps; const { conversationKey } = this.props; // TMEPORARY SOLUTION TO GETTING CONVERSATION UNTIL // SessionConversationStack is created // Get conversation by Key (NOT cid) const conversation = window.getConversationByKey(conversationKey); console.log(`Conversation key: `, conversationKey); return (
{this.renderHeader(conversation)}
{this.renderMessages(conversationKey)}
null} />
); } public renderMessages(conversationKey: string ) { const { messages } = this.state; // FIXME PAY ATTENTION; ONLY RENDER MESSAGES THAT ARE VISIBLE const messagesLength = messages.length; console.log(`Messages`, messages); let messageList = []; messages?.keys.map(key => { const message = messages[key]; return (<>THIS IS A MESSAGE) }); console.log(messages); return messages; // for(let i = messagesLength - 1; i > 0; i--){ // messageList.push({ // isDeletable: true, // text: 'fdgdfg', // direction: 'incoming', // timestamp: '1581565995228', // i18n: window.i18n, // authorPhoneNumber: messages[i].source, // conversationType: 'direct', // previews: [], // isExpired: false, // convoId: messages[i].conversationId, // selected: false, // multiSelectMode: false, // onSelectMessage: () => null, // onSelectMessageUnchecked: () => null, // onShowDetail : () => null, // onShowUserDetails: () => null, // }); // } // console.log(`[vince] MessageList: `, messageList); // return messages && ( // null} // onSelectMessageUnchecked = {() => null} // onShowDetail = {() => null} // onShowUserDetails = {() => null} // /> // ) // return ( // <> // { // messageList.map(message => { // return ( // // )} // ); // } // // ); } public renderHeader(conversation: any) { return ( null} onDeleteMessages={() => null} onDeleteContact={() => null} onResetSession={() => null} onCloseOverlay={() => null} onDeleteSelectedMessages={() => null} onArchive={() => null} onMoveToInbox={() => null} onShowSafetyNumber={() => null} onShowAllMedia={() => null} onShowGroupMembers={() => null} onGoBack={() => null} onBlockUser={() => null} onUnblockUser={() => null} onClearNickname={() => null} onChangeNickname={() => null} onCopyPublicKey={() => null} onLeaveGroup={() => null} onAddModerators={() => null} onRemoveModerators={() => null} onInviteFriends={() => null} /> ); } }