From 3da44d60bff298c004ad625fb6b9c58d8ede3050 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 15 Aug 2020 23:37:50 -0500 Subject: [PATCH] Revert direct_timeline to use /api/v1/timelines/direct, fixes #325 --- app/soapbox/actions/timelines.js | 2 ++ app/soapbox/features/direct_timeline/index.js | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/soapbox/actions/timelines.js b/app/soapbox/actions/timelines.js index d32db8e39..498c89dfb 100644 --- a/app/soapbox/actions/timelines.js +++ b/app/soapbox/actions/timelines.js @@ -168,6 +168,8 @@ export const expandPublicTimeline = ({ maxId, onlyMedia } = {}, done = export const expandCommunityTimeline = ({ maxId, onlyMedia } = {}, done = noOp) => expandTimeline(`community${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/public', { local: true, max_id: maxId, only_media: !!onlyMedia }, done); +export const expandDirectTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('direct', '/api/v1/timelines/direct', { max_id: maxId }, done); + export const expandAccountTimeline = (accountId, { maxId, withReplies } = {}) => expandTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}`, `/api/v1/accounts/${accountId}/statuses`, { exclude_replies: !withReplies, max_id: maxId, with_muted: true }); export const expandAccountFeaturedTimeline = accountId => expandTimeline(`account:${accountId}:pinned`, `/api/v1/accounts/${accountId}/statuses`, { pinned: true, with_muted: true }); diff --git a/app/soapbox/features/direct_timeline/index.js b/app/soapbox/features/direct_timeline/index.js index 996357433..ba7bd32c8 100644 --- a/app/soapbox/features/direct_timeline/index.js +++ b/app/soapbox/features/direct_timeline/index.js @@ -1,18 +1,22 @@ import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types'; +import StatusListContainer from '../ui/containers/status_list_container'; import Column from '../../components/column'; import ColumnHeader from '../../components/column_header'; -import { mountConversations, unmountConversations, expandConversations } from '../../actions/conversations'; +import { expandDirectTimeline } from '../../actions/timelines'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { connectDirectStream } from '../../actions/streaming'; -import ConversationsListContainer from '../conversations/containers/conversations_list_container'; const messages = defineMessages({ title: { id: 'column.direct', defaultMessage: 'Direct messages' }, }); -export default @connect() +const mapStateToProps = state => ({ + hasUnread: state.getIn(['timelines', 'direct', 'unread']) > 0, +}); + +export default @connect(mapStateToProps) @injectIntl class DirectTimeline extends React.PureComponent { @@ -25,14 +29,11 @@ class DirectTimeline extends React.PureComponent { componentDidMount() { const { dispatch } = this.props; - dispatch(mountConversations()); - dispatch(expandConversations()); + dispatch(expandDirectTimeline()); this.disconnect = dispatch(connectDirectStream()); } componentWillUnmount() { - this.props.dispatch(unmountConversations()); - if (this.disconnect) { this.disconnect(); this.disconnect = null; @@ -40,7 +41,7 @@ class DirectTimeline extends React.PureComponent { } handleLoadMore = maxId => { - this.props.dispatch(expandConversations({ maxId })); + this.props.dispatch(expandDirectTimeline({ maxId })); } render() { @@ -48,9 +49,14 @@ class DirectTimeline extends React.PureComponent { return ( - + -