import React, { Component } from 'react' import PropTypes from 'prop-types' import { FaAngleDown, FaRepeat } from 'react-icons/lib/fa' import { MdSearch } from 'react-icons/lib/md' import OpenPendingChannel from 'components/Channels/OpenPendingChannel' import ClosedPendingChannel from 'components/Channels/ClosedPendingChannel' import Channel from 'components/Channels/Channel' 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 fetchChannels() fetchPeers() } render() { const { fetchChannels, closeChannel, channels: { searchQuery, filterPulldown, filter, viewType }, nonActiveFilters, toggleFilterPulldown, changeFilter, currentChannels, updateChannelSearchQuery, openChannelForm, ticker, currentTicker, channelFormProps } = this.props const refreshClicked = () => { // turn the spinner on this.setState({ refreshing: true }) // store event in icon so we dont get an error when react clears it const icon = this.refs.repeat.childNodes // fetch peers fetchChannels() // wait for the svg to appear as child const svgTimeout = setTimeout(() => { if (icon[0].tagName === 'svg') { // spin icon for 1 sec icon[0].style.animation = 'spin 1000ms linear 1' clearTimeout(svgTimeout) } }, 1) // clear animation after the second so we can reuse it const refreshTimeout = setTimeout(() => { icon[0].style.animation = '' this.setState({ refreshing: false }) clearTimeout(refreshTimeout) }, 1000) } return (