Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(ui): don't disable sent filter after sending payment
Browse files Browse the repository at this point in the history
  • Loading branch information
korhaliv committed Nov 8, 2019
1 parent 080aad4 commit 32cb6c9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
11 changes: 6 additions & 5 deletions renderer/components/Pay/Pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { intlShape } from '@zap/i18n'

class Pay extends React.Component {
static propTypes = {
addFilter: PropTypes.func.isRequired,
chain: PropTypes.string.isRequired,
chainName: PropTypes.string.isRequired,
changeFilter: PropTypes.func.isRequired,
channelBalance: PropTypes.number.isRequired,
closeModal: PropTypes.func.isRequired,
cryptoUnit: PropTypes.string.isRequired,
Expand Down Expand Up @@ -208,7 +208,7 @@ class Pay extends React.Component {
routes,
sendCoins,
setRedirectPayReq,
changeFilter,
addFilter,
closeModal,
} = this.props
const { isOnchain } = this.state
Expand Down Expand Up @@ -237,8 +237,9 @@ class Pay extends React.Component {
setRedirectPayReq(null)
}

// Change the transaction filter to ALL transactions
changeFilter('SENT_ACTIVITY')
// Change the transaction filter to include sent and pending transactions
// to ensure user sees freshly added payment
addFilter('SENT_ACTIVITY', 'PENDING_ACTIVITY')
// Close the form modal once the transaction has been sent
closeModal()
}
Expand Down Expand Up @@ -338,7 +339,7 @@ class Pay extends React.Component {
const {
chain,
chainName,
changeFilter,
addFilter,
channelBalance,
closeModal,
cryptoUnit,
Expand Down
4 changes: 2 additions & 2 deletions renderer/containers/Pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Pay } from 'components/Pay'
import { fetchTickers, tickerSelectors } from 'reducers/ticker'
import { setRedirectPayReq, queryFees, queryRoutes } from 'reducers/pay'
import { balanceSelectors } from 'reducers/balance'
import { changeFilter } from 'reducers/activity'
import { addFilter } from 'reducers/activity'
import { channelsSelectors } from 'reducers/channels'
import { sendCoins } from 'reducers/transaction'
import { payInvoice } from 'reducers/payment'
Expand All @@ -28,7 +28,7 @@ const mapStateToProps = state => ({
})

const mapDispatchToProps = {
changeFilter,
addFilter,
closeModal,
fetchTickers,
payInvoice,
Expand Down
42 changes: 32 additions & 10 deletions renderer/reducers/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const initialState = {
export const SHOW_ACTIVITY_MODAL = 'SHOW_ACTIVITY_MODAL'
export const HIDE_ACTIVITY_MODAL = 'HIDE_ACTIVITY_MODAL'
export const CHANGE_FILTER = 'CHANGE_FILTER'
export const ADD_FILTER = 'ADD_FILTER'
export const UPDATE_SEARCH_TEXT = 'UPDATE_SEARCH_TEXT'
export const FETCH_ACTIVITY_HISTORY = 'FETCH_ACTIVITY_HISTORY'
export const FETCH_ACTIVITY_HISTORY_SUCCESS = 'FETCH_ACTIVITY_HISTORY_SUCCESS'
Expand Down Expand Up @@ -269,15 +270,27 @@ export const hideActivityModal = () => dispatch => {
}

/**
* changeFilter - Set the current activity filter.
* changeFilter - Toggle specified activity filter.
*
* @param {string} filter Filter to apply
* @param {...string} filterList Filter to apply
* @returns {object} Action
*/
export function changeFilter(filter) {
export function changeFilter(...filterList) {
return {
type: CHANGE_FILTER,
filter,
filterList,
}
}
/**
* addFilter - Enable specified activity filters.
*
* @param {...string} filterList Filters to apply
* @returns {object} Action
*/
export function addFilter(...filterList) {
return {
type: ADD_FILTER,
filterList,
}
}

Expand Down Expand Up @@ -397,12 +410,21 @@ const ACTION_HANDLERS = {
[HIDE_ACTIVITY_MODAL]: state => {
state.modal = { itemType: null, itemId: null }
},
[CHANGE_FILTER]: (state, { filter }) => {
const { filter: allFilters } = state
if (allFilters.has(filter)) {
allFilters.delete(filter)
} else {
allFilters.add(filter)
[CHANGE_FILTER]: (state, { filterList }) => {
const { filter } = state
filterList.forEach(item => {
if (filter.has(item)) {
filter.delete(item)
} else {
filter.add(item)
}
})
},
[ADD_FILTER]: (state, { filterList }) => {
const { filter } = state
// No filters means all filters are active so no need to add anything
if (filter.size > 0) {
filterList.forEach(item => filter.add(item))
}
},
[UPDATE_SEARCH_TEXT]: (state, { searchText }) => {
Expand Down

0 comments on commit 32cb6c9

Please sign in to comment.