f4512b4411
- Removed status counting in dashboard for admins - Added limit to notifications to only 7 days ago - Removed ability for non-logged in users to view group, group-collection timelines - Limited account realtime search on compose, list, chat actions - Removed fetching of user suggestions - Removed fetching of shortcuts - Removed featured groups, user suggestions timeline injections - Removed group featured panel from explore layout for non logged in users - Removed media gallery panel from profile layout - Removed lists, suggestions, groups panel from home page - Removed user suggestions to list page - Updated pro_timelie in status.rb to find only from 1 hour ago - Updated home timeline to not include groups and to find only latest from 5 days ago - Removed search for non logged in users
143 lines
3.9 KiB
JavaScript
143 lines
3.9 KiB
JavaScript
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { connect } from 'react-redux'
|
|
import throttle from 'lodash.throttle'
|
|
import { defineMessages, injectIntl } from 'react-intl'
|
|
import { openModal } from '../actions/modal'
|
|
import {
|
|
MODAL_HOME_TIMELINE_SETTINGS,
|
|
LAZY_LOAD_SCROLL_OFFSET,
|
|
} from '../constants'
|
|
import { me } from '../initial_state'
|
|
import PageTitle from '../features/ui/util/page_title'
|
|
import DefaultLayout from '../layouts/default_layout'
|
|
import TimelineComposeBlock from '../components/timeline_compose_block'
|
|
import TabBar from '../components/tab_bar'
|
|
import WrappedBundle from '../features/ui/util/wrapped_bundle'
|
|
import {
|
|
UserPanel,
|
|
GroupsPanel,
|
|
LinkFooter,
|
|
ListsPanel,
|
|
TrendsBreakingPanel,
|
|
UserSuggestionsPanel,
|
|
ProPanel,
|
|
ShopPanel,
|
|
ProgressPanel,
|
|
} from '../features/ui/util/async_components'
|
|
|
|
class HomePage extends React.PureComponent {
|
|
|
|
state = {
|
|
lazyLoaded: false,
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.window = window
|
|
this.documentElement = document.scrollingElement || document.documentElement
|
|
|
|
this.window.addEventListener('scroll', this.handleScroll)
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.detachScrollListener()
|
|
}
|
|
|
|
detachScrollListener = () => {
|
|
this.window.removeEventListener('scroll', this.handleScroll)
|
|
}
|
|
|
|
handleScroll = throttle(() => {
|
|
if (this.window) {
|
|
const { scrollTop } = this.documentElement
|
|
|
|
if (scrollTop > LAZY_LOAD_SCROLL_OFFSET && !this.state.lazyLoaded) {
|
|
this.setState({ lazyLoaded: true })
|
|
this.detachScrollListener()
|
|
}
|
|
}
|
|
}, 150, {
|
|
trailing: true,
|
|
})
|
|
|
|
onOpenHomePageSettingsModal = () => {
|
|
this.props.dispatch(openModal(MODAL_HOME_TIMELINE_SETTINGS))
|
|
}
|
|
|
|
render() {
|
|
const {
|
|
children,
|
|
intl,
|
|
isPro,
|
|
totalQueuedItemsCount,
|
|
unreadChatsCount,
|
|
} = this.props
|
|
const { lazyLoaded } = this.state
|
|
|
|
const title = intl.formatMessage(messages.home)
|
|
|
|
return (
|
|
<DefaultLayout
|
|
page='home'
|
|
title={title}
|
|
actions={[
|
|
{
|
|
icon: 'tv',
|
|
href: 'https://tv.gab.com',
|
|
},
|
|
{
|
|
icon: 'chat',
|
|
to: '/messages',
|
|
count: unreadChatsCount,
|
|
},
|
|
{
|
|
icon: 'search',
|
|
to: '/search',
|
|
},
|
|
]}
|
|
layout={[
|
|
UserPanel,
|
|
ProgressPanel,
|
|
<WrappedBundle component={ProPanel} componentParams={{ isPro: isPro }} />,
|
|
<WrappedBundle component={TrendsBreakingPanel} />,
|
|
<WrappedBundle component={ShopPanel} componentParams={{ isLazy: true, shouldLoad: lazyLoaded }} />,
|
|
// <WrappedBundle component={ListsPanel} componentParams={{ isLazy: true, shouldLoad: lazyLoaded }} />,
|
|
// <WrappedBundle component={UserSuggestionsPanel} componentParams={{ isLazy: true, shouldLoad: lazyLoaded }} />,
|
|
// <WrappedBundle component={GroupsPanel} componentParams={{ isLazy: true, shouldLoad: lazyLoaded, groupType: 'member' }} />,
|
|
LinkFooter,
|
|
]}
|
|
>
|
|
|
|
<PageTitle
|
|
path={title}
|
|
badge={totalQueuedItemsCount}
|
|
/>
|
|
|
|
<TimelineComposeBlock autoFocus={false} />
|
|
{children}
|
|
|
|
</DefaultLayout>
|
|
)
|
|
}
|
|
}
|
|
|
|
const messages = defineMessages({
|
|
home: { id: 'home', defaultMessage: 'Home' },
|
|
})
|
|
|
|
const mapStateToProps = (state) => ({
|
|
totalQueuedItemsCount: state.getIn(['timelines', 'home', 'totalQueuedItemsCount']),
|
|
unreadChatsCount: state.getIn(['chats', 'chatsUnreadCount']),
|
|
isPro: state.getIn(['accounts', me, 'is_pro']),
|
|
})
|
|
|
|
HomePage.propTypes = {
|
|
children: PropTypes.node.isRequired,
|
|
dispatch: PropTypes.func.isRequired,
|
|
intl: PropTypes.object.isRequired,
|
|
isPro: PropTypes.bool,
|
|
unreadChatsCount: PropTypes.number.isRequired,
|
|
totalQueuedItemsCount: PropTypes.number.isRequired,
|
|
}
|
|
|
|
export default injectIntl(connect(mapStateToProps)(HomePage)) |