|
|
@ -12,6 +12,14 @@ import ChannelForm from 'components/ChannelForm' |
|
|
|
import styles from './Channels.scss' |
|
|
|
|
|
|
|
class Channels extends Component { |
|
|
|
constructor(props) { |
|
|
|
super(props) |
|
|
|
|
|
|
|
this.state = { |
|
|
|
refreshing: false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
componentWillMount() { |
|
|
|
const { fetchChannels, fetchPeers } = this.props |
|
|
|
|
|
|
@ -48,24 +56,50 @@ class Channels extends Component { |
|
|
|
channelFormProps |
|
|
|
} = this.props |
|
|
|
|
|
|
|
const refreshClicked = (event) => { |
|
|
|
const refreshClicked = event => { |
|
|
|
// turn the spinner on
|
|
|
|
this.setState({ refreshing: true }) |
|
|
|
|
|
|
|
// store event in icon so we dont get an error when react clears it
|
|
|
|
const icon = event.currentTarget |
|
|
|
let icon = this.refs.repeat.childNodes |
|
|
|
|
|
|
|
// fetch channels
|
|
|
|
// fetch peers
|
|
|
|
fetchChannels() |
|
|
|
|
|
|
|
// clear animation after the second so we can reuse it
|
|
|
|
setTimeout(() => { icon.style.animation = '' }, 1000) |
|
|
|
// wait for the svg to appear as child
|
|
|
|
let svgTimeout = setTimeout(() => { |
|
|
|
if (icon[0].tagName === 'svg') { |
|
|
|
// spin icon for 1 sec
|
|
|
|
icon[0].style.animation = 'spin 1000ms linear 1' |
|
|
|
clearTimeout(svgTimeout) |
|
|
|
} |
|
|
|
}, 1) |
|
|
|
|
|
|
|
// spin icon for 1 sec
|
|
|
|
icon.style.animation = 'spin 1000ms linear 1' |
|
|
|
// clear animation after the second so we can reuse it
|
|
|
|
let refreshTimeout = setTimeout(() => { |
|
|
|
icon[0].style.animation = '' |
|
|
|
this.setState({ refreshing: false }) |
|
|
|
clearTimeout(refreshTimeout) |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|
<div className={`${styles.container} ${viewType === 1 && styles.graphview}`}> |
|
|
|
<ChannelForm {...channelFormProps} /> |
|
|
|
|
|
|
|
<header className={styles.header}> |
|
|
|
<div className={styles.titleContainer}> |
|
|
|
<div className={styles.left}> |
|
|
|
<h1>Channels</h1> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className={styles.createChannelContainer}> |
|
|
|
<div className={`buttonPrimary ${styles.newChannelButton}`} onClick={openChannelForm}> |
|
|
|
Create new channel |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</header> |
|
|
|
|
|
|
|
<div className={styles.search}> |
|
|
|
<label className={`${styles.label} ${styles.input}`} htmlFor='channelSearch'> |
|
|
|
<MdSearch /> |
|
|
@ -79,13 +113,6 @@ class Channels extends Component { |
|
|
|
id='channelSearch' |
|
|
|
/> |
|
|
|
</div> |
|
|
|
<header className={styles.header}> |
|
|
|
<div className={styles.createChannelContainer}> |
|
|
|
<div className={`buttonPrimary ${styles.newChannelButton}`} onClick={openChannelForm}> |
|
|
|
Create new channel |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</header> |
|
|
|
|
|
|
|
<div className={styles.filtersContainer}> |
|
|
|
<section> |
|
|
@ -102,11 +129,15 @@ class Channels extends Component { |
|
|
|
} |
|
|
|
</ul> |
|
|
|
</section> |
|
|
|
<section className={`${styles.refreshContainer} hint--left`} data-hint='Refresh your channels list'> |
|
|
|
<FaRepeat |
|
|
|
style={{ verticalAlign: 'baseline' }} |
|
|
|
onClick={refreshClicked} |
|
|
|
/> |
|
|
|
<section className={styles.refreshContainer}> |
|
|
|
<span className={styles.refresh} onClick={refreshClicked} ref='repeat'> |
|
|
|
{ |
|
|
|
this.state.refreshing ? |
|
|
|
<FaRepeat /> |
|
|
|
: |
|
|
|
'Refresh' |
|
|
|
} |
|
|
|
</span> |
|
|
|
</section> |
|
|
|
</div> |
|
|
|
|
|
|
|