import React, { Component } from 'react' import PropTypes from 'prop-types' import Isvg from 'react-inlinesvg' import { MdSearch } from 'react-icons/lib/md' import { FaAngleDown, FaRepeat } from 'react-icons/lib/fa' import ContactModal from 'components/Contacts/ContactModal' import ContactsForm from 'components/Contacts/ContactsForm' import OnlineContact from 'components/Contacts/OnlineContact' import PendingContact from 'components/Contacts/PendingContact' import ClosingContact from 'components/Contacts/ClosingContact' import OfflineContact from 'components/Contacts/OfflineContact' import LoadingContact from 'components/Contacts/LoadingContact' import plus from 'icons/plus.svg' import styles from './Contacts.scss' class Contacts extends Component { constructor(props) { super(props) this.state = { refreshing: false } } componentWillMount() { const { fetchChannels, fetchPeers, fetchDescribeNetwork } = this.props fetchChannels() fetchPeers() fetchDescribeNetwork() } render() { const { channels: { searchQuery, filterPulldown, filter, loadingChannelPubkeys, closingChannelIds }, currentChannels, activeChannels, fetchChannels, updateChannelSearchQuery, toggleFilterPulldown, changeFilter, nonActiveFilters, openContactsForm, openContactModal, contactModalProps, contactsFormProps } = 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.repeat.childNodes // fetch channels 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 (

Contacts ({activeChannels.length} online)

Add
updateChannelSearchQuery(event.target.value)} className={`${styles.text} ${styles.input}`} placeholder='Search your contacts list...' type='text' id='channelSearch' />

{filter.name}

    { nonActiveFilters.map(f => (
  • changeFilter(f)}> {f.name}
  • )) }
{ this.repeat = ref }}> { this.state.refreshing ? : 'Refresh' }
    { loadingChannelPubkeys.map(pubkey => ) } { currentChannels.length > 0 && currentChannels.map((channel, index) => { if (closingChannelIds.includes(channel.chan_id)) { return } else if (Object.prototype.hasOwnProperty.call(channel, 'blocks_till_open')) { return } else if (Object.prototype.hasOwnProperty.call(channel, 'closing_txid')) { return } else if (!channel.active) { return } return }) }
) } } Contacts.propTypes = { fetchPeers: PropTypes.func.isRequired, fetchDescribeNetwork: PropTypes.func.isRequired, channels: PropTypes.object.isRequired, currentChannels: PropTypes.array.isRequired, activeChannels: PropTypes.array.isRequired, fetchChannels: PropTypes.func.isRequired, updateChannelSearchQuery: PropTypes.func.isRequired, toggleFilterPulldown: PropTypes.func.isRequired, changeFilter: PropTypes.func.isRequired, nonActiveFilters: PropTypes.array.isRequired, openContactsForm: PropTypes.func.isRequired, openContactModal: PropTypes.func.isRequired, contactModalProps: PropTypes.object.isRequired, contactsFormProps: PropTypes.object.isRequired } export default Contacts