2020-08-15 21:18:53 -07:00
import PropTypes from 'prop-types' ;
2022-01-10 14:17:52 -08:00
import React from 'react' ;
2022-03-21 11:09:01 -07:00
import { defineMessages , injectIntl } from 'react-intl' ;
2022-01-10 14:17:52 -08:00
import { connect } from 'react-redux' ;
2022-01-10 14:25:06 -08:00
2022-01-10 14:01:24 -08:00
import { directComposeById } from 'soapbox/actions/compose' ;
2022-01-10 14:25:06 -08:00
2020-08-15 21:18:53 -07:00
import { mountConversations , unmountConversations , expandConversations } from '../../actions/conversations' ;
import { connectDirectStream } from '../../actions/streaming' ;
2022-03-21 11:09:01 -07:00
import { Card , CardBody , Column , Stack , Text } from '../../components/ui' ;
2020-08-15 21:18:53 -07:00
const messages = defineMessages ( {
title : { id : 'column.direct' , defaultMessage : 'Direct messages' } ,
2021-10-14 10:25:51 -07:00
searchPlaceholder : { id : 'direct.search_placeholder' , defaultMessage : 'Send a message to…' } ,
2022-03-21 11:09:01 -07:00
body : { id : 'direct.body' , defaultMessage : 'A new direct messaging experience will be available soon. Please stay tuned.' } ,
2020-08-15 21:18:53 -07:00
} ) ;
export default @ connect ( )
@ injectIntl
class ConversationsTimeline extends React . PureComponent {
static propTypes = {
dispatch : PropTypes . func . isRequired ,
intl : PropTypes . object . isRequired ,
hasUnread : PropTypes . bool ,
} ;
componentDidMount ( ) {
const { dispatch } = this . props ;
dispatch ( mountConversations ( ) ) ;
dispatch ( expandConversations ( ) ) ;
this . disconnect = dispatch ( connectDirectStream ( ) ) ;
}
componentWillUnmount ( ) {
this . props . dispatch ( unmountConversations ( ) ) ;
if ( this . disconnect ) {
this . disconnect ( ) ;
this . disconnect = null ;
}
}
2021-10-14 09:52:12 -07:00
handleSuggestion = accountId => {
this . props . dispatch ( directComposeById ( accountId ) ) ;
}
2020-08-15 21:18:53 -07:00
handleLoadMore = maxId => {
this . props . dispatch ( expandConversations ( { maxId } ) ) ;
}
render ( ) {
2022-03-21 11:09:01 -07:00
const { intl } = this . props ;
2020-08-15 21:18:53 -07:00
return (
2022-03-21 11:09:01 -07:00
< Column label = { intl . formatMessage ( messages . title ) } transparent >
< Card variant = 'rounded' >
< CardBody >
< Stack space = { 2 } >
< Text size = 'lg' align = 'center' weight = 'bold' > { intl . formatMessage ( messages . title ) } < / T e x t >
< Text theme = 'muted' align = 'center' > { intl . formatMessage ( messages . body ) } < / T e x t >
< / S t a c k >
< / C a r d B o d y >
< / C a r d >
2020-08-15 21:18:53 -07:00
< / C o l u m n >
) ;
2022-03-21 11:09:01 -07:00
// return (
// <Column label={intl.formatMessage(messages.title)}>
// <ColumnHeader icon='envelope' active={hasUnread} title={intl.formatMessage(messages.title)} />
// <AccountSearch
// placeholder={intl.formatMessage(messages.searchPlaceholder)}
// onSelected={this.handleSuggestion}
// />
// <ConversationsListContainer
// scrollKey='direct_timeline'
// timelineId='direct'
// onLoadMore={this.handleLoadMore}
// emptyMessage={<FormattedMessage id='empty_column.direct' defaultMessage="You don't have any direct messages yet. When you send or receive one, it will show up here." />}
// />
// </Column>
// );
2020-08-15 21:18:53 -07:00
}
}