From b56cf3bf7daea8f5e09c267afe08f1f7ab1fba14 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Thu, 4 Jan 2018 12:20:46 -0600 Subject: [PATCH] fix(contacts): rename friend functions to contacts --- .../{FriendsForm.js => ContactsForm.js} | 33 +++++++---------- .../{FriendsForm.scss => ContactsForm.scss} | 4 +- .../{friendsform.js => contactsform.js} | 37 +++++++++---------- app/reducers/index.js | 4 +- app/routes/contacts/components/Contacts.js | 10 ++--- .../contacts/containers/ContactsContainer.js | 30 +++++++-------- 6 files changed, 56 insertions(+), 62 deletions(-) rename app/components/Contacts/{FriendsForm.js => ContactsForm.js} (81%) rename app/components/Contacts/{FriendsForm.scss => ContactsForm.scss} (97%) rename app/reducers/{friendsform.js => contactsform.js} (51%) diff --git a/app/components/Contacts/FriendsForm.js b/app/components/Contacts/ContactsForm.js similarity index 81% rename from app/components/Contacts/FriendsForm.js rename to app/components/Contacts/ContactsForm.js index d6984409..48056162 100644 --- a/app/components/Contacts/FriendsForm.js +++ b/app/components/Contacts/ContactsForm.js @@ -3,12 +3,12 @@ import PropTypes from 'prop-types' import ReactModal from 'react-modal' import { MdClose } from 'react-icons/lib/md' import { FaCircle } from 'react-icons/lib/fa' -import styles from './FriendsForm.scss' +import styles from './ContactsForm.scss' -const FriendsForm = ({ - friendsform, - closeFriendsForm, - updateFriendFormSearchQuery, +const ContactsForm = ({ + contactsform, + closeContactsForm, + updateContactFormSearchQuery, openChannel, activeChannelPubkeys, @@ -16,12 +16,7 @@ const FriendsForm = ({ pendingOpenChannelPubkeys, filteredNetworkNodes }) => { - console.log('pendingOpenChannelPubkeys: ', pendingOpenChannelPubkeys) const renderRightSide = (node) => { - if (node.addresses.length > 1) { - console.log('node: ', node) - } - if (activeChannelPubkeys.includes(node.pub_key)) { return ( @@ -68,11 +63,11 @@ const FriendsForm = ({ return (
closeFriendsForm} + onRequestClose={() => closeContactsForm} parentSelector={() => document.body} className={styles.modal} > @@ -80,7 +75,7 @@ const FriendsForm = ({

Add Contact

-
+
@@ -89,17 +84,17 @@ const FriendsForm = ({
updateFriendFormSearchQuery(event.target.value)} + value={contactsform.searchQuery} + onChange={event => updateContactFormSearchQuery(event.target.value)} autoFocus />
    { - friendsform.searchQuery.length > 0 && filteredNetworkNodes.map(node => { + contactsform.searchQuery.length > 0 && filteredNetworkNodes.map(node => { return (
  • @@ -139,8 +134,8 @@ const FriendsForm = ({ ) } -FriendsForm.propTypes = { +ContactsForm.propTypes = { } -export default FriendsForm +export default ContactsForm diff --git a/app/components/Contacts/FriendsForm.scss b/app/components/Contacts/ContactsForm.scss similarity index 97% rename from app/components/Contacts/FriendsForm.scss rename to app/components/Contacts/ContactsForm.scss index bd675257..87e02e99 100644 --- a/app/components/Contacts/FriendsForm.scss +++ b/app/components/Contacts/ContactsForm.scss @@ -69,7 +69,7 @@ vertical-align: middle; &:nth-child(1) { - font-size: 16px; + font-size: 14px; font-weight: bold; letter-spacing: 1.3px; } @@ -77,7 +77,7 @@ &:nth-child(2) { color: $darkestgrey; font-size: 12px; - line-height: 16px; + line-height: 14px; } } } diff --git a/app/reducers/friendsform.js b/app/reducers/contactsform.js similarity index 51% rename from app/reducers/friendsform.js rename to app/reducers/contactsform.js index a3e037b2..9cd171b7 100644 --- a/app/reducers/friendsform.js +++ b/app/reducers/contactsform.js @@ -5,35 +5,34 @@ import filter from 'lodash/filter' // Initial State const initialState = { isOpen: false, - searchQuery: '', - friend: '' + searchQuery: '' } // Constants // ------------------------------------ -export const OPEN_FRIENDS_FORM = 'OPEN_FRIENDS_FORM' -export const CLOSE_FRIENDS_FORM = 'CLOSE_FRIENDS_FORM' +export const OPEN_CONTACTS_FORM = 'OPEN_CONTACTS_FORM' +export const CLOSE_CONTACTS_FORM = 'CLOSE_CONTACTS_FORM' -export const UPDATE_FRIEND_FORM_SEARCH_QUERY = 'UPDATE_FRIEND_FORM_SEARCH_QUERY' +export const UPDATE_CONTACT_FORM_SEARCH_QUERY = 'UPDATE_CONTACT_FORM_SEARCH_QUERY' // ------------------------------------ // Actions // ------------------------------------ -export function openFriendsForm() { +export function openContactsForm() { return { - type: OPEN_FRIENDS_FORM + type: OPEN_CONTACTS_FORM } } -export function closeFriendsForm() { +export function closeContactsForm() { return { - type: CLOSE_FRIENDS_FORM + type: CLOSE_CONTACTS_FORM } } -export function updateFriendFormSearchQuery(searchQuery) { +export function updateContactFormSearchQuery(searchQuery) { return { - type: UPDATE_FRIEND_FORM_SEARCH_QUERY, + type: UPDATE_CONTACT_FORM_SEARCH_QUERY, searchQuery } } @@ -42,32 +41,32 @@ export function updateFriendFormSearchQuery(searchQuery) { // Action Handlers // ------------------------------------ const ACTION_HANDLERS = { - [OPEN_FRIENDS_FORM]: state => ({ ...state, isOpen: true }), - [CLOSE_FRIENDS_FORM]: state => ({ ...state, isOpen: false }), + [OPEN_CONTACTS_FORM]: state => ({ ...state, isOpen: true }), + [CLOSE_CONTACTS_FORM]: state => ({ ...state, isOpen: false }), - [UPDATE_FRIEND_FORM_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery }) + [UPDATE_CONTACT_FORM_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery }) } // ------------------------------------ // Selector // ------------------------------------ -const friendFormSelectors = {} +const contactFormSelectors = {} const networkNodesSelector = state => state.network.nodes -const searchQuerySelector = state => state.friendsform.searchQuery +const searchQuerySelector = state => state.contactsform.searchQuery -friendFormSelectors.filteredNetworkNodes = createSelector( +contactFormSelectors.filteredNetworkNodes = createSelector( networkNodesSelector, searchQuerySelector, (nodes, searchQuery) => filter(nodes, node => node.alias.includes(searchQuery) || node.pub_key.includes(searchQuery)) ) -export { friendFormSelectors } +export { contactFormSelectors } // ------------------------------------ // Reducer // ------------------------------------ -export default function friendFormReducer(state = initialState, action) { +export default function contactFormReducer(state = initialState, action) { const handler = ACTION_HANDLERS[action.type] return handler ? handler(state, action) : state diff --git a/app/reducers/index.js b/app/reducers/index.js index f3d06968..5abdb652 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -10,7 +10,7 @@ import peers from './peers' import channels from './channels' import channelform from './channelform' -import friendsform from './friendsform' +import contactsform from './contactsform' import form from './form' import payform from './payform' @@ -34,7 +34,7 @@ const rootReducer = combineReducers({ peers, channels, channelform, - friendsform, + contactsform, form, payform, diff --git a/app/routes/contacts/components/Contacts.js b/app/routes/contacts/components/Contacts.js index 637c9d31..159765e7 100644 --- a/app/routes/contacts/components/Contacts.js +++ b/app/routes/contacts/components/Contacts.js @@ -8,7 +8,7 @@ import { FaAngleDown, FaRepeat } from 'react-icons/lib/fa' import { btc } from 'utils' -import FriendsForm from 'components/Contacts/FriendsForm' +import ContactsForm from 'components/Contacts/ContactsForm' import OnlineContact from 'components/Contacts/OnlineContact' import PendingContact from 'components/Contacts/PendingContact' import ClosingContact from 'components/Contacts/ClosingContact' @@ -55,9 +55,9 @@ class Contacts extends Component { changeFilter, nonActiveFilters, - openFriendsForm, + openContactsForm, - friendsFormProps, + contactsFormProps, peers } = this.props @@ -91,7 +91,7 @@ class Contacts extends Component { return (
    - +
    @@ -100,7 +100,7 @@ class Contacts extends Component {
    -
    +
    Add
    diff --git a/app/routes/contacts/containers/ContactsContainer.js b/app/routes/contacts/containers/ContactsContainer.js index a1a28744..3b40491c 100644 --- a/app/routes/contacts/containers/ContactsContainer.js +++ b/app/routes/contacts/containers/ContactsContainer.js @@ -18,18 +18,18 @@ import { fetchPeers } from 'reducers/peers' import { fetchDescribeNetwork } from 'reducers/network' import { - openFriendsForm, - closeFriendsForm, - updateFriendFormSearchQuery, - friendFormSelectors -} from 'reducers/friendsform' + openContactsForm, + closeContactsForm, + updateContactFormSearchQuery, + contactFormSelectors +} from 'reducers/contactsform' import Contacts from '../components/Contacts' const mapDispatchToProps = { - openFriendsForm, - closeFriendsForm, - updateFriendFormSearchQuery, + openContactsForm, + closeContactsForm, + updateContactFormSearchQuery, openChannel, updateChannelSearchQuery, toggleFilterPulldown, @@ -44,7 +44,7 @@ const mapStateToProps = state => ({ channels: state.channels, peers: state.peers, network: state.network, - friendsform: state.friendsform, + contactsform: state.contactsform, currentChannels: currentChannels(state), activeChannels: channelsSelectors.activeChannels(state), @@ -56,16 +56,16 @@ const mapStateToProps = state => ({ closingPendingChannels: channelsSelectors.closingPendingChannels(state), nonActiveFilters: channelsSelectors.nonActiveFilters(state), - filteredNetworkNodes: friendFormSelectors.filteredNetworkNodes(state) + filteredNetworkNodes: contactFormSelectors.filteredNetworkNodes(state) }) const mergeProps = (stateProps, dispatchProps, ownProps) => { - const friendsFormProps = { - closeFriendsForm: dispatchProps.closeFriendsForm, - updateFriendFormSearchQuery: dispatchProps.updateFriendFormSearchQuery, + const contactsFormProps = { + closeContactsForm: dispatchProps.closeContactsForm, + updateContactFormSearchQuery: dispatchProps.updateContactFormSearchQuery, openChannel: dispatchProps.openChannel, - friendsform: stateProps.friendsform, + contactsform: stateProps.contactsform, filteredNetworkNodes: stateProps.filteredNetworkNodes, activeChannelPubkeys: stateProps.activeChannelPubkeys, @@ -78,7 +78,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { ...dispatchProps, ...ownProps, - friendsFormProps + contactsFormProps } }