gab-social/app/javascript/gabsocial/pages/home_page.js

123 lines
3.6 KiB
JavaScript
Raw Normal View History

2020-02-08 06:12:01 +00:00
import { Fragment } from 'react'
2020-03-24 04:39:12 +00:00
import { openModal } from '../actions/modal'
2020-04-16 07:00:43 +01:00
import { defineMessages, injectIntl } from 'react-intl'
2020-04-28 06:33:58 +01:00
import IntersectionObserverArticle from '../components/intersection_observer_article'
import IntersectionObserverWrapper from '../features/ui/util/intersection_observer_wrapper'
2020-04-11 23:29:19 +01:00
import PageTitle from '../features/ui/util/page_title'
2020-04-04 00:18:26 +01:00
import GroupsPanel from '../components/panel/groups_panel'
import ListsPanel from '../components/panel/lists_panel'
2020-02-08 06:12:01 +00:00
import LinkFooter from '../components/link_footer'
import WhoToFollowPanel from '../components/panel/who_to_follow_panel'
import ProgressPanel from '../components/panel/progress_panel'
2020-02-19 23:57:07 +00:00
import UserPanel from '../components/panel/user_panel'
import TrendsPanel from '../components/panel/trends_panel'
2020-02-24 21:56:07 +00:00
import DefaultLayout from '../layouts/default_layout'
2020-02-08 06:12:01 +00:00
import TimelineComposeBlock from '../components/timeline_compose_block'
2020-02-19 23:57:07 +00:00
import Divider from '../components/divider'
2020-04-16 07:00:43 +01:00
const messages = defineMessages({
home: { id: 'home', defaultMessage: 'Home' },
})
const mapStateToProps = (state) => ({
totalQueuedItemsCount: state.getIn(['timelines', 'home', 'totalQueuedItemsCount']),
})
2020-03-24 04:39:12 +00:00
const mapDispatchToProps = (dispatch) => ({
onOpenHomePageSettingsModal() {
dispatch(openModal('HOME_TIMELINE_SETTINGS'))
},
})
2020-02-19 23:57:07 +00:00
2020-03-24 04:39:12 +00:00
export default
2020-04-16 07:00:43 +01:00
@injectIntl
@connect(mapStateToProps, mapDispatchToProps)
2020-03-24 04:39:12 +00:00
class HomePage extends PureComponent {
static propTypes = {
2020-04-16 07:00:43 +01:00
intl: PropTypes.object.isRequired,
children: PropTypes.node.isRequired,
totalQueuedItemsCount: PropTypes.number.isRequired,
2020-03-24 04:39:12 +00:00
onOpenHomePageSettingsModal: PropTypes.func.isRequired,
2020-03-12 16:09:15 +00:00
}
2020-04-28 06:33:58 +01:00
intersectionObserverWrapper = new IntersectionObserverWrapper()
componentDidMount() {
this.attachIntersectionObserver()
}
componentWillUnmount() {
this.detachIntersectionObserver()
}
attachIntersectionObserver() {
this.intersectionObserverWrapper.connect()
}
detachIntersectionObserver() {
this.intersectionObserverWrapper.disconnect()
}
2020-02-08 06:12:01 +00:00
render() {
2020-04-16 07:00:43 +01:00
const {
intl,
children,
totalQueuedItemsCount,
onOpenHomePageSettingsModal,
} = this.props
return (
2020-02-17 17:50:29 +00:00
<DefaultLayout
2020-04-16 07:00:43 +01:00
title={intl.formatMessage(messages.home)}
2020-02-19 23:57:07 +00:00
actions={[
{
icon: 'ellipsis',
2020-03-24 04:39:12 +00:00
onClick: onOpenHomePageSettingsModal,
2020-02-19 23:57:07 +00:00
},
]}
2020-02-17 17:50:29 +00:00
layout={(
<Fragment>
<UserPanel />
<ProgressPanel />
2020-02-19 23:57:07 +00:00
<TrendsPanel />
2020-04-28 06:33:58 +01:00
<IntersectionObserverArticle
id={'home-sidebar-lists-panel'}
listLength={7}
index={4}
intersectionObserverWrapper={this.intersectionObserverWrapper}
>
<ListsPanel />
</IntersectionObserverArticle>
<IntersectionObserverArticle
id={'home-sidebar-wtf-panel'}
listLength={7}
index={5}
intersectionObserverWrapper={this.intersectionObserverWrapper}
>
<WhoToFollowPanel />
</IntersectionObserverArticle>
<IntersectionObserverArticle
id={'home-sidebar-groups-panel'}
listLength={7}
index={6}
intersectionObserverWrapper={this.intersectionObserverWrapper}
>
<GroupsPanel isLazy />
</IntersectionObserverArticle>
2020-02-17 17:50:29 +00:00
<LinkFooter />
</Fragment>
)}
>
2020-04-16 07:00:43 +01:00
<PageTitle
path={intl.formatMessage(messages.home)}
badge={totalQueuedItemsCount}
/>
2020-02-28 15:20:47 +00:00
<TimelineComposeBlock autoFocus={false} />
2020-02-19 23:57:07 +00:00
<Divider />
2020-02-08 06:12:01 +00:00
{children}
2020-02-17 17:50:29 +00:00
</DefaultLayout>
)
}
}