diff --git a/.eslintrc b/.eslintrc
index 69ccec87..5ae6e558 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -46,7 +46,8 @@
"array": false,
"object": true
}],
- "prefer-promise-reject-errors": 0
+ "prefer-promise-reject-errors": 0,
+ "no-param-reassign": [2, { "props": false }]
},
"plugins": [
"flowtype",
diff --git a/app/components/Wallet/ReceiveModal.js b/app/components/Wallet/ReceiveModal.js
index 2d94bf27..e1145421 100644
--- a/app/components/Wallet/ReceiveModal.js
+++ b/app/components/Wallet/ReceiveModal.js
@@ -106,7 +106,7 @@ ReceiveModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
pubkey: PropTypes.string,
address: PropTypes.string.isRequired,
- alias: PropTypes.string.isRequired,
+ alias: PropTypes.string,
closeReceiveModal: PropTypes.func.isRequired
}
diff --git a/app/components/Wallet/Wallet.scss b/app/components/Wallet/Wallet.scss
index 7b9b8ecd..86a84bfd 100644
--- a/app/components/Wallet/Wallet.scss
+++ b/app/components/Wallet/Wallet.scss
@@ -163,16 +163,17 @@
font-size: 16px;
font-weight: bold;
color: $white;
- background: $spaceblue;
- padding: 15px;
+ background: #31343F;
+ padding: 10px;
width: 100px;
text-align: center;
border-radius: 5px;
cursor: pointer;
+ opacity: 0.5;
transition: all 0.25s;
&:hover {
- opacity: 0.5;
+ opacity: 1;
}
&:nth-child(1) {
diff --git a/app/reducers/activity.js b/app/reducers/activity.js
index c71cc19d..2c6d402d 100644
--- a/app/reducers/activity.js
+++ b/app/reducers/activity.js
@@ -10,8 +10,7 @@ const initialState = {
{ key: 'ALL_ACTIVITY', name: 'All' },
{ key: 'SENT_ACTIVITY', name: 'Sent' },
{ key: 'REQUESTED_ACTIVITY', name: 'Requested' },
- { key: 'PENDING_ACTIVITY', name: 'Pending' },
- { key: 'FUNDED_ACTIVITY', name: 'Funding Transactions' }
+ { key: 'PENDING_ACTIVITY', name: 'Pending' }
],
modal: {
modalType: null,
@@ -105,13 +104,58 @@ const searchSelector = state => state.activity.searchText
const paymentsSelector = state => state.payment.payments
const invoicesSelector = state => state.invoice.invoices
const transactionsSelector = state => state.transaction.transactions
-const channelsSelector = state => state.channels.channels
const invoiceExpired = (invoice) => {
const expiresAt = (parseInt(invoice.creation_date, 10) + parseInt(invoice.expiry, 10))
return expiresAt < (Date.now() / 1000)
}
+// helper function that returns invoice, payment or transaction timestamp
+function returnTimestamp(transaction) {
+ // if on-chain txn
+ if (Object.prototype.hasOwnProperty.call(transaction, 'time_stamp')) { return transaction.time_stamp }
+ // if invoice that has been paid
+ if (transaction.settled) { return transaction.settle_date }
+ // if invoice that has not been paid or an LN payment
+ return transaction.creation_date
+}
+
+// getMonth() returns the month in 0 index (0 for Jan), so we create an arr of the
+// string representation we want for the UI
+const months = ['Jan', 'Feb', 'Mar', 'April', 'May', 'June', 'July', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+
+// groups the data by day
+function groupData(data) {
+ return data.reduce((arr, el) => {
+ const d = new Date(returnTimestamp(el) * 1000)
+ const date = d.getDate()
+ const title = `${months[d.getMonth()]} ${date}, ${d.getFullYear()}`
+
+ if (!arr[title]) { arr[title] = [] }
+
+ arr[title].push({ el })
+
+ return arr
+ }, {})
+}
+
+// takes the result of groupData and returns an array
+function groupArray(data) {
+ return Object.keys(data).map(title => ({ title, activity: data[title] }))
+}
+
+// sorts data form new to old according to the timestamp
+function sortNewToOld(data) {
+ return data.sort((a, b) => new Date(b.title).getTime() - new Date(a.title).getTime())
+}
+
+// take in a dataset and return an array grouped by day
+function groupAll(data) {
+ const groups = groupData(data)
+ const groupArrays = groupArray(groups)
+ return sortNewToOld(groupArrays)
+}
+
const allActivity = createSelector(
searchSelector,
paymentsSelector,
@@ -128,66 +172,33 @@ const allActivity = createSelector(
return false
})
- return searchedArr.sort((a, b) => {
- // this will return the correct timestamp to use when sorting (time_stamp, creation_date, or settle_date)
- function returnTimestamp(transaction) {
- // if on-chain txn
- if (Object.prototype.hasOwnProperty.call(transaction, 'time_stamp')) { return transaction.time_stamp }
- // if invoice that has been paid
- if (transaction.settled) { return transaction.settle_date }
- // if invoice that has not been paid or an LN payment
- return transaction.creation_date
- }
-
- const aTimestamp = returnTimestamp(a)
- const bTimestamp = returnTimestamp(b)
+ if (!searchedArr.length) { return [] }
- return bTimestamp - aTimestamp
- })
+ return groupAll(searchedArr)
}
)
const invoiceActivity = createSelector(
invoicesSelector,
- invoices => invoices
+ invoices => groupAll(invoices)
)
const sentActivity = createSelector(
transactionsSelector,
paymentsSelector,
- (transactions, payments) => {
- const sentTransactions = transactions.filter(transaction => transaction.amount < 0)
- return [...sentTransactions, ...payments].sort((a, b) => {
- const aTimestamp = Object.prototype.hasOwnProperty.call(a, 'time_stamp') ? a.time_stamp : a.creation_date
- const bTimestamp = Object.prototype.hasOwnProperty.call(b, 'time_stamp') ? b.time_stamp : b.creation_date
-
- return bTimestamp - aTimestamp
- })
- }
+ (transactions, payments) => groupAll([...transactions.filter(transaction => transaction.amount < 0), ...payments])
)
const pendingActivity = createSelector(
invoicesSelector,
- invoices => invoices.filter(invoice => !invoice.settled && !invoiceExpired(invoice))
-)
-
-const fundedActivity = createSelector(
- transactionsSelector,
- channelsSelector,
- (transactions, channels) => {
- const fundingTxIds = channels.map(channel => channel.channel_point.split(':')[0])
- const fundingTxs = transactions.filter(transaction => fundingTxIds.includes(transaction.tx_hash))
-
- return fundingTxs.sort((a, b) => b.time_stamp - a.time_stamp)
- }
+ invoices => groupAll(invoices.filter(invoice => !invoice.settled && !invoiceExpired(invoice)))
)
const FILTERS = {
ALL_ACTIVITY: allActivity,
SENT_ACTIVITY: sentActivity,
REQUESTED_ACTIVITY: invoiceActivity,
- PENDING_ACTIVITY: pendingActivity,
- FUNDED_ACTIVITY: fundedActivity
+ PENDING_ACTIVITY: pendingActivity
}
activitySelectors.currentActivity = createSelector(
diff --git a/app/routes/activity/components/Activity.js b/app/routes/activity/components/Activity.js
index 7ea8b984..c9b964c4 100644
--- a/app/routes/activity/components/Activity.js
+++ b/app/routes/activity/components/Activity.js
@@ -27,17 +27,40 @@ class Activity extends Component {
}
renderActivity(activity) {
- const { ticker, currentTicker, showActivityModal } = this.props
+ const {
+ ticker,
+ currentTicker,
+ showActivityModal,
+ network,
+ currencyName
+ } = this.props
if (Object.prototype.hasOwnProperty.call(activity, 'block_hash')) {
// activity is an on-chain tx
- return