loading improvments for profile media panel

This commit is contained in:
Mary Kate 2020-08-15 15:19:18 -05:00
parent 99d96ed901
commit 422588178a

View file

@ -35,13 +35,19 @@ class ProfileMediaPanel extends ImmutablePureComponent {
this.props.dispatch(expandAccountMediaTimeline(accountId)); this.props.dispatch(expandAccountMediaTimeline(accountId));
} }
render() { componentDidUpdate() {
const { attachments } = this.props; const { account } = this.props;
const nineAttachments = attachments.slice(0, 9); const accountId = account.get('id');
this.props.dispatch(expandAccountMediaTimeline(accountId));
}
if (attachments.isEmpty()) { render() {
return null; const { attachments, account } = this.props;
} const nineAttachments = attachments.slice(0, 9);
//
// if (attachments.isEmpty()) {
// return null;
// }
return ( return (
<div className='media-panel'> <div className='media-panel'>
@ -51,18 +57,20 @@ class ProfileMediaPanel extends ImmutablePureComponent {
<FormattedMessage id='media_panel.title' defaultMessage='Media' /> <FormattedMessage id='media_panel.title' defaultMessage='Media' />
</span> </span>
</div> </div>
<div className='media-panel__content'> {account &&
<div className='media-panel__list'> <div className='media-panel__content'>
{nineAttachments.map((attachment, index) => ( <div className='media-panel__list'>
<MediaItem {!nineAttachments.isEmpty() && nineAttachments.map((attachment, index) => (
key={`${attachment.getIn(['status', 'id'])}+${attachment.get('id')}`} <MediaItem
attachment={attachment} key={`${attachment.getIn(['status', 'id'])}+${attachment.get('id')}`}
displayWidth={255} attachment={attachment}
onOpenMedia={this.handleOpenMedia} displayWidth={255}
/> onOpenMedia={this.handleOpenMedia}
))} />
))}
</div>
</div> </div>
</div> }
</div> </div>
); );
}; };