Browse Source

fix(contacts): rename friend functions to contacts

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
b56cf3bf7d
  1. 33
      app/components/Contacts/ContactsForm.js
  2. 4
      app/components/Contacts/ContactsForm.scss
  3. 37
      app/reducers/contactsform.js
  4. 4
      app/reducers/index.js
  5. 10
      app/routes/contacts/components/Contacts.js
  6. 30
      app/routes/contacts/containers/ContactsContainer.js

33
app/components/Contacts/FriendsForm.js → 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 (
<span className={`${styles.online} ${styles.inactive}`}>
@ -68,11 +63,11 @@ const FriendsForm = ({
return (
<div>
<ReactModal
isOpen={friendsform.isOpen}
isOpen={contactsform.isOpen}
contentLabel='No Overlay Click Modal'
ariaHideApp
shouldCloseOnOverlayClick
onRequestClose={() => closeFriendsForm}
onRequestClose={() => closeContactsForm}
parentSelector={() => document.body}
className={styles.modal}
>
@ -80,7 +75,7 @@ const FriendsForm = ({
<div>
<h1>Add Contact</h1>
</div>
<div onClick={closeFriendsForm} className={styles.modalClose}>
<div onClick={closeContactsForm} className={styles.modalClose}>
<MdClose />
</div>
</header>
@ -89,17 +84,17 @@ const FriendsForm = ({
<div className={styles.search}>
<input
type='text'
placeholder='Find friend by alias or pubkey'
placeholder='Find contact by alias or pubkey'
className={styles.searchInput}
value={friendsform.searchQuery}
onChange={event => updateFriendFormSearchQuery(event.target.value)}
value={contactsform.searchQuery}
onChange={event => updateContactFormSearchQuery(event.target.value)}
autoFocus
/>
</div>
<ul className={styles.networkResults}>
{
friendsform.searchQuery.length > 0 && filteredNetworkNodes.map(node => {
contactsform.searchQuery.length > 0 && filteredNetworkNodes.map(node => {
return (
<li key={node.pub_key}>
<section>
@ -139,8 +134,8 @@ const FriendsForm = ({
)
}
FriendsForm.propTypes = {
ContactsForm.propTypes = {
}
export default FriendsForm
export default ContactsForm

4
app/components/Contacts/FriendsForm.scss → 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;
}
}
}

37
app/reducers/friendsform.js → 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

4
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,

10
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 (
<div className={styles.friendsContainer}>
<FriendsForm {...friendsFormProps} />
<ContactsForm {...contactsFormProps} />
<header className={styles.header}>
<div className={styles.titleContainer}>
@ -100,7 +100,7 @@ class Contacts extends Component {
</div>
</div>
<div className={styles.newFriendContainer}>
<div className={`buttonPrimary ${styles.newFriendButton}`} onClick={openFriendsForm}>
<div className={`buttonPrimary ${styles.newFriendButton}`} onClick={openContactsForm}>
<Isvg src={plus} />
<span>Add</span>
</div>

30
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
}
}

Loading…
Cancel
Save