Added timeline injections when empty Home timeline or Notifications
• Added: - timeline injections when empty Home timeline or Notifications on all tab
This commit is contained in:
parent
15f9d7f955
commit
b9f15b28a6
@ -7,6 +7,11 @@ import ImmutablePureComponent from 'react-immutable-pure-component'
|
|||||||
import { createSelector } from 'reselect'
|
import { createSelector } from 'reselect'
|
||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
import { me, promotions } from '../initial_state'
|
import { me, promotions } from '../initial_state'
|
||||||
|
import {
|
||||||
|
TIMELINE_INJECTION_FEATURED_GROUPS,
|
||||||
|
TIMELINE_INJECTION_GROUP_CATEGORIES,
|
||||||
|
TIMELINE_INJECTION_USER_SUGGESTIONS,
|
||||||
|
} from '../constants'
|
||||||
import { dequeueTimeline, scrollTopTimeline } from '../actions/timelines'
|
import { dequeueTimeline, scrollTopTimeline } from '../actions/timelines'
|
||||||
import { showTimelineInjection } from '../actions/timeline_injections'
|
import { showTimelineInjection } from '../actions/timeline_injections'
|
||||||
import { fetchStatus, fetchContext } from '../actions/statuses'
|
import { fetchStatus, fetchContext } from '../actions/statuses'
|
||||||
@ -15,6 +20,7 @@ import StatusPlaceholder from './placeholder/status_placeholder'
|
|||||||
import ScrollableList from './scrollable_list'
|
import ScrollableList from './scrollable_list'
|
||||||
import TimelineQueueButtonHeader from './timeline_queue_button_header'
|
import TimelineQueueButtonHeader from './timeline_queue_button_header'
|
||||||
import TimelineInjectionBase from './timeline_injections/timeline_injection_base'
|
import TimelineInjectionBase from './timeline_injections/timeline_injection_base'
|
||||||
|
import TimelineInjectionRoot from './timeline_injections/timeline_injection_root'
|
||||||
|
|
||||||
class StatusList extends ImmutablePureComponent {
|
class StatusList extends ImmutablePureComponent {
|
||||||
|
|
||||||
@ -175,6 +181,8 @@ class StatusList extends ImmutablePureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let scrollableContent = []
|
let scrollableContent = []
|
||||||
|
let emptyContent = []
|
||||||
|
const canShowEmptyContent = scrollableContent.length === 0 && statusIds.size === 0 && scrollKey === 'home_timeline'
|
||||||
|
|
||||||
if (isLoading || statusIds.size > 0) {
|
if (isLoading || statusIds.size > 0) {
|
||||||
for (let i = 0; i < statusIds.count(); i++) {
|
for (let i = 0; i < statusIds.count(); i++) {
|
||||||
@ -255,6 +263,15 @@ class StatusList extends ImmutablePureComponent {
|
|||||||
)).concat(scrollableContent)
|
)).concat(scrollableContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canShowEmptyContent) {
|
||||||
|
emptyContent = [
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_USER_SUGGESTIONS} key='empty-injection-0' />,
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_FEATURED_GROUPS} key='empty-injection-1' />,
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_USER_SUGGESTIONS} props={{suggestionType:'verified'}} key='empty-injection-2' />,
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_GROUP_CATEGORIES} key='empty-injection-3' />,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<TimelineQueueButtonHeader
|
<TimelineQueueButtonHeader
|
||||||
@ -278,6 +295,12 @@ class StatusList extends ImmutablePureComponent {
|
|||||||
>
|
>
|
||||||
{scrollableContent}
|
{scrollableContent}
|
||||||
</ScrollableList>
|
</ScrollableList>
|
||||||
|
{
|
||||||
|
canShowEmptyContent &&
|
||||||
|
<div className={[_s.d, _s.mt15, _s.w100PC].join(' ')}>
|
||||||
|
{emptyContent}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,18 @@ import {
|
|||||||
dequeueNotifications,
|
dequeueNotifications,
|
||||||
forceDequeueNotifications,
|
forceDequeueNotifications,
|
||||||
} from '../actions/notifications'
|
} from '../actions/notifications'
|
||||||
|
import {
|
||||||
|
TIMELINE_INJECTION_FEATURED_GROUPS,
|
||||||
|
TIMELINE_INJECTION_GROUP_CATEGORIES,
|
||||||
|
TIMELINE_INJECTION_USER_SUGGESTIONS,
|
||||||
|
} from '../constants'
|
||||||
import NotificationContainer from '../containers/notification_container'
|
import NotificationContainer from '../containers/notification_container'
|
||||||
import ScrollableList from '../components/scrollable_list'
|
import ScrollableList from '../components/scrollable_list'
|
||||||
import TimelineQueueButtonHeader from '../components/timeline_queue_button_header'
|
import TimelineQueueButtonHeader from '../components/timeline_queue_button_header'
|
||||||
import Block from '../components/block'
|
import Block from '../components/block'
|
||||||
import Account from '../components/account'
|
import Account from '../components/account'
|
||||||
import NotificationPlaceholder from '../components/placeholder/notification_placeholder'
|
import NotificationPlaceholder from '../components/placeholder/notification_placeholder'
|
||||||
|
import TimelineInjectionRoot from '../components/timeline_injections/timeline_injection_root'
|
||||||
|
|
||||||
class Notifications extends ImmutablePureComponent {
|
class Notifications extends ImmutablePureComponent {
|
||||||
|
|
||||||
@ -78,6 +84,7 @@ class Notifications extends ImmutablePureComponent {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
|
notifications,
|
||||||
sortedNotifications,
|
sortedNotifications,
|
||||||
isLoading,
|
isLoading,
|
||||||
hasMore,
|
hasMore,
|
||||||
@ -87,6 +94,8 @@ class Notifications extends ImmutablePureComponent {
|
|||||||
const { changedTabs } = this.state
|
const { changedTabs } = this.state
|
||||||
|
|
||||||
let scrollableContent = null
|
let scrollableContent = null
|
||||||
|
let emptyContent = []
|
||||||
|
const canShowEmptyContent = !scrollableContent && !isLoading && notifications.size === 0 && selectedFilter === 'all'
|
||||||
|
|
||||||
if (isLoading && this.scrollableContent && !changedTabs) {
|
if (isLoading && this.scrollableContent && !changedTabs) {
|
||||||
scrollableContent = this.scrollableContent
|
scrollableContent = this.scrollableContent
|
||||||
@ -122,6 +131,16 @@ class Notifications extends ImmutablePureComponent {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canShowEmptyContent) {
|
||||||
|
emptyContent = [
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_USER_SUGGESTIONS} key='empty-injection-0' />,
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_FEATURED_GROUPS} key='empty-injection-1' />,
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_USER_SUGGESTIONS} props={{suggestionType:'verified'}} key='empty-injection-2' />,
|
||||||
|
<TimelineInjectionRoot type={TIMELINE_INJECTION_GROUP_CATEGORIES} key='empty-injection-3' />,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.scrollableContent = scrollableContent
|
this.scrollableContent = scrollableContent
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -147,6 +166,13 @@ class Notifications extends ImmutablePureComponent {
|
|||||||
{scrollableContent}
|
{scrollableContent}
|
||||||
</ScrollableList>
|
</ScrollableList>
|
||||||
</Block>
|
</Block>
|
||||||
|
|
||||||
|
{
|
||||||
|
canShowEmptyContent &&
|
||||||
|
<div className={[_s.d, _s.mt15, _s.w100PC].join(' ')}>
|
||||||
|
{emptyContent}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user