From ab6dd338c91087dfe871d0dac254fed78c677a5e Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Fri, 20 Oct 2017 21:55:49 -0500 Subject: [PATCH] feature(refresh peers): ability to refresh peers --- app/components/Peers/Peers.js | 72 ++++++++++++++++++-------- app/components/Peers/Peers.scss | 14 +++++ app/routes/wallet/components/Wallet.js | 2 + 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/app/components/Peers/Peers.js b/app/components/Peers/Peers.js index 5df2b11e..e90a0cbd 100644 --- a/app/components/Peers/Peers.js +++ b/app/components/Peers/Peers.js @@ -1,12 +1,14 @@ import React from 'react' import PropTypes from 'prop-types' import { TiPlus } from 'react-icons/lib/ti' +import { FaRepeat } from 'react-icons/lib/fa' import PeerModal from './PeerModal' import PeerForm from './PeerForm' import Peer from './Peer' import styles from './Peers.scss' const Peers = ({ + fetchPeers, peersLoading, peers, setPeer, @@ -16,30 +18,56 @@ const Peers = ({ setPeerForm, connect, disconnect -}) => ( -
- - -
-

Peers

-
setPeerForm({ isOpen: true })} - > - +}) => { + const refreshClicked = (event) => { + // store event in icon so we dont get an error when react clears it + let icon = event.currentTarget + + // fetch peers + fetchPeers() + + // clear animation after the second so we can reuse it + setTimeout(() => icon.style.animation = '', 1000) + + // spin icon for 1 sec + icon.style.animation = 'spin 1000ms linear 1' + } + + return ( +
+ + +
+

Peers

+ + + +
setPeerForm({ isOpen: true })} + > + +
+
    + { + !peersLoading ? + peers.map(peer => ) + : + 'Loading...' + } +
-
    - { - !peersLoading ? - peers.map(peer => ) - : - 'Loading...' - } -
-
-) + ) +} Peers.propTypes = { peersLoading: PropTypes.bool.isRequired, diff --git a/app/components/Peers/Peers.scss b/app/components/Peers/Peers.scss index f24f6f70..613ce641 100644 --- a/app/components/Peers/Peers.scss +++ b/app/components/Peers/Peers.scss @@ -15,6 +15,20 @@ text-align: left; } + .refresh { + cursor: pointer; + margin-left: 5px; + font-size: 12px; + vertical-align: top; + color: $darkestgrey; + line-height: 14px; + transition: color 0.25s; + + &:hover { + color: $main; + } + } + .connectPeer { float: right; cursor: pointer; diff --git a/app/routes/wallet/components/Wallet.js b/app/routes/wallet/components/Wallet.js index 62081b61..07bc1a09 100644 --- a/app/routes/wallet/components/Wallet.js +++ b/app/routes/wallet/components/Wallet.js @@ -21,6 +21,7 @@ class Wallet extends Component { ticker, peers: { peersLoading, peers, peer, peerForm }, channels: { channelsLoading, channels, channel, channelForm, pendingChannels }, + fetchPeers, fetchChannels, setPeer, setChannel, @@ -54,6 +55,7 @@ class Wallet extends Component {