|
|
|
@ -9,15 +9,23 @@ import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/col |
|
|
|
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; |
|
|
|
|
import ColumnSettingsContainer from './containers/column_settings_container'; |
|
|
|
|
import { Link } from 'react-router-dom'; |
|
|
|
|
import { fetchAnnouncements, toggleShowAnnouncements } from 'flavours/glitch/actions/announcements'; |
|
|
|
|
import AnnouncementsContainer from 'flavours/glitch/features/getting_started/containers/announcements_container'; |
|
|
|
|
import classNames from 'classnames'; |
|
|
|
|
import IconWithBadge from 'flavours/glitch/components/icon_with_badge'; |
|
|
|
|
|
|
|
|
|
const messages = defineMessages({ |
|
|
|
|
title: { id: 'column.home', defaultMessage: 'Home' }, |
|
|
|
|
show_announcements: { id: 'home.show_announcements', defaultMessage: 'Show announcements' }, |
|
|
|
|
hide_announcements: { id: 'home.hide_announcements', defaultMessage: 'Hide announcements' }, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({ |
|
|
|
|
hasUnread: state.getIn(['timelines', 'home', 'unread']) > 0, |
|
|
|
|
isPartial: state.getIn(['timelines', 'home', 'isPartial']), |
|
|
|
|
hasAnnouncements: !state.getIn(['announcements', 'items']).isEmpty(), |
|
|
|
|
unreadAnnouncements: state.getIn(['announcements', 'unread']).size, |
|
|
|
|
showAnnouncements: state.getIn(['announcements', 'show']), |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps) |
|
|
|
@ -31,6 +39,9 @@ class HomeTimeline extends React.PureComponent { |
|
|
|
|
isPartial: PropTypes.bool, |
|
|
|
|
columnId: PropTypes.string, |
|
|
|
|
multiColumn: PropTypes.bool, |
|
|
|
|
hasAnnouncements: PropTypes.bool, |
|
|
|
|
unreadAnnouncements: PropTypes.number, |
|
|
|
|
showAnnouncements: PropTypes.bool, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
handlePin = () => { |
|
|
|
@ -61,6 +72,7 @@ class HomeTimeline extends React.PureComponent { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
componentDidMount () { |
|
|
|
|
this.props.dispatch(fetchAnnouncements()); |
|
|
|
|
this._checkIfReloadNeeded(false, this.props.isPartial); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -93,10 +105,31 @@ class HomeTimeline extends React.PureComponent { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleToggleAnnouncementsClick = (e) => { |
|
|
|
|
e.stopPropagation(); |
|
|
|
|
this.props.dispatch(toggleShowAnnouncements()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
|
const { intl, hasUnread, columnId, multiColumn } = this.props; |
|
|
|
|
const { intl, hasUnread, columnId, multiColumn, hasAnnouncements, unreadAnnouncements, showAnnouncements } = this.props; |
|
|
|
|
const pinned = !!columnId; |
|
|
|
|
|
|
|
|
|
let announcementsButton = null; |
|
|
|
|
|
|
|
|
|
if (hasAnnouncements) { |
|
|
|
|
announcementsButton = ( |
|
|
|
|
<button |
|
|
|
|
className={classNames('column-header__button', { 'active': showAnnouncements })} |
|
|
|
|
title={intl.formatMessage(showAnnouncements ? messages.hide_announcements : messages.show_announcements)} |
|
|
|
|
aria-label={intl.formatMessage(showAnnouncements ? messages.hide_announcements : messages.show_announcements)} |
|
|
|
|
aria-pressed={showAnnouncements ? 'true' : 'false'} |
|
|
|
|
onClick={this.handleToggleAnnouncementsClick} |
|
|
|
|
> |
|
|
|
|
<IconWithBadge id='bullhorn' count={unreadAnnouncements} /> |
|
|
|
|
</button> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Column bindToDocument={!multiColumn} ref={this.setRef} name='home' label={intl.formatMessage(messages.title)}> |
|
|
|
|
<ColumnHeader |
|
|
|
@ -108,13 +141,14 @@ class HomeTimeline extends React.PureComponent { |
|
|
|
|
onClick={this.handleHeaderClick} |
|
|
|
|
pinned={pinned} |
|
|
|
|
multiColumn={multiColumn} |
|
|
|
|
extraButton={announcementsButton} |
|
|
|
|
> |
|
|
|
|
<ColumnSettingsContainer /> |
|
|
|
|
</ColumnHeader> |
|
|
|
|
|
|
|
|
|
{hasAnnouncements && showAnnouncements && <AnnouncementsContainer />} |
|
|
|
|
|
|
|
|
|
<StatusListContainer |
|
|
|
|
prepend={<AnnouncementsContainer />} |
|
|
|
|
alwaysPrepend |
|
|
|
|
trackScroll={!pinned} |
|
|
|
|
scrollKey={`home_timeline-${columnId}`} |
|
|
|
|
onLoadMore={this.handleLoadMore} |
|
|
|
|