Updated ui.js to home, notifications differently
• Updated: - ui.js to home, notifications differently... - if landing on home page, on initial it loads home timeline - if landing on notifications page, on initial it loads notifications - if landing on any other page it does not load home, notifications until you navigate to the home/notifications page for the first time
This commit is contained in:
parent
a4ede5f599
commit
83696f8098
@ -245,6 +245,8 @@ class UI extends PureComponent {
|
||||
}
|
||||
|
||||
state = {
|
||||
fetchedHome: false,
|
||||
fetchedNotifications: false,
|
||||
draggingOver: false,
|
||||
}
|
||||
|
||||
@ -372,9 +374,13 @@ class UI extends PureComponent {
|
||||
window.setTimeout(() => Notification.requestPermission(), 120 * 1000)
|
||||
}
|
||||
|
||||
if (this.context.router.route.location.pathname === '/home') {
|
||||
const pathname = this.context.router.route.location.pathname
|
||||
|
||||
if (pathname === '/home') {
|
||||
this.setState({ fetchedHome: true })
|
||||
this.props.dispatch(expandHomeTimeline())
|
||||
} else if (this.context.router.route.location.pathname === '/notifications') {
|
||||
} else if (pathname.startsWith('/notifications')) {
|
||||
this.setState({ fetchedNotifications: true })
|
||||
this.props.dispatch(expandNotifications())
|
||||
}
|
||||
|
||||
@ -396,6 +402,20 @@ class UI extends PureComponent {
|
||||
document.removeEventListener('dragend', this.handleDragEnd)
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.location !== prevProps.location) {
|
||||
const pathname = this.props.location.pathname
|
||||
|
||||
if (pathname === '/home' && !this.state.fetchedHome) {
|
||||
this.setState({ fetchedHome: true })
|
||||
this.props.dispatch(expandHomeTimeline())
|
||||
} else if (pathname.startsWith('/notifications') && !this.state.fetchedNotifications) {
|
||||
this.setState({ fetchedNotifications: true })
|
||||
this.props.dispatch(expandNotifications())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setRef = (c) => {
|
||||
this.node = c
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user