This commit is contained in:
mgabdev
2020-04-17 01:35:46 -04:00
parent 35852e7fee
commit 4d7aee59c9
37 changed files with 568 additions and 319 deletions

View File

@@ -12,15 +12,17 @@ const messages = defineMessages({
const emptyList = ImmutableList()
const mapStateToProps = (state, { account, withReplies = false }) => {
const mapStateToProps = (state, { account, commentsOnly = false }) => {
const accountId = !!account ? account.getIn(['id'], null) : -1
const path = withReplies ? `${accountId}:with_replies` : accountId
const path = commentsOnly ? `${accountId}:comments_only` : accountId
console.log("commentsOnly, path:", commentsOnly, path)
return {
accountId,
statusIds: state.getIn(['timelines', `account:${path}`, 'items'], emptyList),
featuredStatusIds: withReplies ? ImmutableList() : state.getIn(['timelines', `account:${accountId}:pinned`, 'items'], emptyList),
featuredStatusIds: commentsOnly ? ImmutableList() : state.getIn(['timelines', `account:${accountId}:pinned`, 'items'], emptyList),
isLoading: state.getIn(['timelines', `account:${path}`, 'isLoading']),
hasMore: state.getIn(['timelines', `account:${path}`, 'hasMore']),
}
@@ -38,33 +40,33 @@ class AccountTimeline extends ImmutablePureComponent {
featuredStatusIds: ImmutablePropTypes.list,
isLoading: PropTypes.bool,
hasMore: PropTypes.bool,
withReplies: PropTypes.bool,
commentsOnly: PropTypes.bool,
intl: PropTypes.object.isRequired,
}
componentWillMount() {
const { accountId, withReplies } = this.props
const { accountId, commentsOnly } = this.props
if (accountId && accountId !== -1) {
this.props.dispatch(fetchAccountIdentityProofs(accountId))
if (!withReplies) {
if (!commentsOnly) {
this.props.dispatch(expandAccountFeaturedTimeline(accountId))
}
this.props.dispatch(expandAccountTimeline(accountId, { withReplies }))
this.props.dispatch(expandAccountTimeline(accountId, { commentsOnly }))
}
}
componentWillReceiveProps(nextProps) {
if (nextProps.accountId && nextProps.accountId !== -1 && (nextProps.accountId !== this.props.accountId && nextProps.accountId) || nextProps.withReplies !== this.props.withReplies) {
if (nextProps.accountId && nextProps.accountId !== -1 && (nextProps.accountId !== this.props.accountId && nextProps.accountId) || nextProps.commentsOnly !== this.props.commentsOnly) {
this.props.dispatch(fetchAccountIdentityProofs(nextProps.accountId))
if (!nextProps.withReplies) {
if (!nextProps.commentsOnly) {
this.props.dispatch(expandAccountFeaturedTimeline(nextProps.accountId))
}
this.props.dispatch(expandAccountTimeline(nextProps.accountId, { withReplies: nextProps.withReplies }))
this.props.dispatch(expandAccountTimeline(nextProps.accountId, { commentsOnly: nextProps.commentsOnly }))
}
}
@@ -72,7 +74,7 @@ class AccountTimeline extends ImmutablePureComponent {
if (this.props.accountId && this.props.accountId !== -1) {
this.props.dispatch(expandAccountTimeline(this.props.accountId, {
maxId,
withReplies: this.props.withReplies
commentsOnly: this.props.commentsOnly
}))
}
}
@@ -89,6 +91,8 @@ class AccountTimeline extends ImmutablePureComponent {
if (!account) return null
console.log("statusIds:", statusIds)
return (
<StatusList
scrollKey='account_timeline'

View File

@@ -193,8 +193,8 @@ class ComposeForm extends ImmutablePureComponent {
selectionStart = selectionEnd;
}
this.autosuggestTextarea.textbox.setSelectionRange(selectionStart, selectionEnd);
this.autosuggestTextarea.textbox.focus();
// this.autosuggestTextarea.textbox.setSelectionRange(selectionStart, selectionEnd);
// this.autosuggestTextarea.textbox.focus();
}
}
@@ -332,6 +332,14 @@ class ComposeForm extends ImmutablePureComponent {
</div>
}
{ /*
(isUploading || hasGif) &&
<div className={[_s.default, _s.px15].join(' ')}>
<UploadForm replyToId={replyToId} />
</div>
*/
}
{
!edit && hasPoll &&
<div className={[_s.default, _s.px15].join(' ')}>

View File

@@ -0,0 +1,39 @@
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ProgressBar from '../../../../components/progress_bar'
import Upload from '../media_upload_item'
import SensitiveMediaButton from '../sensitive_media_button'
const mapStateToProps = (state) => ({
mediaIds: state.getIn(['compose', 'media_attachments']).map(item => item.get('id')),
isUploading: state.getIn(['compose', 'is_uploading']),
uploadProgress: state.getIn(['compose', 'progress']),
});
export default
@connect(mapStateToProps)
class GifForm extends ImmutablePureComponent {
static propTypes = {
mediaIds: ImmutablePropTypes.list.isRequired,
isUploading: PropTypes.bool,
uploadProgress: PropTypes.number,
};
render () {
const {
mediaIds,
isUploading,
uploadProgress,
} = this.props
return (
<div className={_s.default}>
<div className={[_s.default, _s.flexRow, _s.flexWrap].join(' ')}>
<Upload id={id} key={id} />
</div>
</div>
)
}
}

View File

@@ -1,8 +1,8 @@
import ImmutablePropTypes from 'react-immutable-proptypes'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ProgressBar from '../../../../components/progress_bar'
import Upload from '../media_upload_item'
import SensitiveMediaButton from '../sensitive_media_button'
import ProgressBar from '../../../components/progress_bar'
import Upload from './media_upload_item'
import SensitiveMediaButton from './sensitive_media_button'
const mapStateToProps = (state) => ({
mediaIds: state.getIn(['compose', 'media_attachments']).map(item => item.get('id')),

View File

@@ -1 +0,0 @@
export { default } from './upload_form'

View File

@@ -1,10 +0,0 @@
.compose-form-upload-wrapper {
overflow: hidden;
}
.compose-form-uploads-wrapper {
display: flex;
flex-direction: row;
padding: 5px;
flex-wrap: wrap;
}

View File

@@ -111,7 +111,6 @@ const makeMapStateToProps = () => {
ancestorsIds,
descendantsIds,
askReplyConfirmation: state.getIn(['compose', 'text']).trim().length !== 0,
domain: state.getIn(['meta', 'domain']),
};
};
@@ -135,7 +134,7 @@ class Status extends ImmutablePureComponent {
descendantsIds: ImmutablePropTypes.list,
intl: PropTypes.object.isRequired,
askReplyConfirmation: PropTypes.bool,
domain: PropTypes.string.isRequired,
contextType: PropTypes.string,
};
state = {
@@ -412,7 +411,8 @@ class Status extends ImmutablePureComponent {
ancestorsIds,
descendantsIds,
intl,
domain
contextType,
commentsLimited,
} = this.props
let ancestors, descendants
@@ -441,11 +441,13 @@ class Status extends ImmutablePureComponent {
toggleSensitive: this.handleHotkeyToggleSensitive,
};
console.log("descendantsIds.size > 0:", descendantsIds.size > 0)
return (
<div ref={this.setRef} className={_s.mb15}>
<Block>
{
/* ancestors */
/* : todo : ancestors if is comment */
}
<HotKeys handlers={handlers}>
@@ -453,13 +455,10 @@ class Status extends ImmutablePureComponent {
<StatusContainer
id={status.get('id')}
contextType={'timelineId'}
showThread
borderless={descendantsIds && descendantsIds.size > 0}
contextType={contextType}
// onOpenVideo={this.handleOpenVideo}
// onOpenMedia={this.handleOpenMedia}
// onToggleHidden={this.handleToggleHidden}
// domain={domain}
// showMedia={this.state.showMedia}
// onToggleMediaVisibility={this.handleToggleMediaVisibility}
/>
@@ -472,7 +471,10 @@ class Status extends ImmutablePureComponent {
<div className={[_s.default, _s.mr10, _s.ml10, _s.mb10, _s.borderColorSecondary, _s.borderBottom1PX].join(' ')}/>
}
<CommentList descendants={descendantsIds} />
<CommentList
commentsLimited={commentsLimited}
descendants={descendantsIds}
/>
</Block>
</div>
)