Commit 83696f80 authored by mgabdev's avatar mgabdev

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
parent a4ede5f5
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment