|
|
@ -1,6 +1,7 @@ |
|
|
|
import React, {Component, PropTypes} from 'react' |
|
|
|
import React, {Component, PropTypes} from 'react' |
|
|
|
import Markdown from 'react-markdown' |
|
|
|
import Markdown from 'react-markdown' |
|
|
|
import {connect} from 'react-redux'; |
|
|
|
import {connect} from 'react-redux' |
|
|
|
|
|
|
|
import debounce from 'lodash.debounce' |
|
|
|
import {markNoticeRead} from '../../../../ui/app/actions' |
|
|
|
import {markNoticeRead} from '../../../../ui/app/actions' |
|
|
|
import Identicon from '../../../../ui/app/components/identicon' |
|
|
|
import Identicon from '../../../../ui/app/components/identicon' |
|
|
|
import Breadcrumbs from './breadcrumbs' |
|
|
|
import Breadcrumbs from './breadcrumbs' |
|
|
@ -20,23 +21,46 @@ class NoticeScreen extends Component { |
|
|
|
lastUnreadNotice: {} |
|
|
|
lastUnreadNotice: {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state = { |
|
|
|
|
|
|
|
atBottom: false, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
|
|
|
this.onScroll() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
acceptTerms = () => { |
|
|
|
acceptTerms = () => { |
|
|
|
const { markNoticeRead, lastUnreadNotice, next } = this.props; |
|
|
|
const { markNoticeRead, lastUnreadNotice, next } = this.props; |
|
|
|
const defer = markNoticeRead(lastUnreadNotice) |
|
|
|
const defer = markNoticeRead(lastUnreadNotice) |
|
|
|
|
|
|
|
.then(() => this.setState({ atBottom: false })) |
|
|
|
|
|
|
|
|
|
|
|
if ((/terms/gi).test(lastUnreadNotice.title)) { |
|
|
|
if ((/terms/gi).test(lastUnreadNotice.title)) { |
|
|
|
defer.then(next) |
|
|
|
defer.then(next) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onScroll = debounce(() => { |
|
|
|
|
|
|
|
if (this.state.atBottom) return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const target = document.querySelector('.tou__body') |
|
|
|
|
|
|
|
const {scrollTop, offsetHeight, scrollHeight} = target; |
|
|
|
|
|
|
|
const atBottom = scrollTop + offsetHeight >= scrollHeight; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setState({atBottom: atBottom}) |
|
|
|
|
|
|
|
}, 25) |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|
const { |
|
|
|
const { |
|
|
|
address, |
|
|
|
address, |
|
|
|
lastUnreadNotice: { title, body } |
|
|
|
lastUnreadNotice: { title, body } |
|
|
|
} = this.props; |
|
|
|
} = this.props; |
|
|
|
|
|
|
|
const { atBottom } = this.state |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="tou"> |
|
|
|
<div |
|
|
|
|
|
|
|
className="tou" |
|
|
|
|
|
|
|
onScroll={this.onScroll} |
|
|
|
|
|
|
|
> |
|
|
|
<Identicon address={address} diameter={70} /> |
|
|
|
<Identicon address={address} diameter={70} /> |
|
|
|
<div className="tou__title">{title}</div> |
|
|
|
<div className="tou__title">{title}</div> |
|
|
|
<Markdown |
|
|
|
<Markdown |
|
|
@ -46,7 +70,8 @@ class NoticeScreen extends Component { |
|
|
|
/> |
|
|
|
/> |
|
|
|
<button |
|
|
|
<button |
|
|
|
className="first-time-flow__button" |
|
|
|
className="first-time-flow__button" |
|
|
|
onClick={this.acceptTerms} |
|
|
|
onClick={atBottom && this.acceptTerms} |
|
|
|
|
|
|
|
disabled={!atBottom} |
|
|
|
> |
|
|
|
> |
|
|
|
Accept |
|
|
|
Accept |
|
|
|
</button> |
|
|
|
</button> |
|
|
|