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,14 +35,20 @@ class ProfileMediaPanel extends ImmutablePureComponent {
this.props.dispatch(expandAccountMediaTimeline(accountId));
}
render() {
const { attachments } = this.props;
const nineAttachments = attachments.slice(0, 9);
if (attachments.isEmpty()) {
return null;
componentDidUpdate() {
const { account } = this.props;
const accountId = account.get('id');
this.props.dispatch(expandAccountMediaTimeline(accountId));
}
render() {
const { attachments, account } = this.props;
const nineAttachments = attachments.slice(0, 9);
//
// if (attachments.isEmpty()) {
// return null;
// }
return (
<div className='media-panel'>
<div className='media-panel-header'>
@ -51,9 +57,10 @@ class ProfileMediaPanel extends ImmutablePureComponent {
<FormattedMessage id='media_panel.title' defaultMessage='Media' />
</span>
</div>
{account &&
<div className='media-panel__content'>
<div className='media-panel__list'>
{nineAttachments.map((attachment, index) => (
{!nineAttachments.isEmpty() && nineAttachments.map((attachment, index) => (
<MediaItem
key={`${attachment.getIn(['status', 'id'])}+${attachment.get('id')}`}
attachment={attachment}
@ -63,6 +70,7 @@ class ProfileMediaPanel extends ImmutablePureComponent {
))}
</div>
</div>
}
</div>
);
};