Merge pull request #257 from status-im/fix/purge

fix: purge not actually urging, but now it does
This commit is contained in:
Iuri Matias 2019-05-21 16:58:35 -04:00 committed by GitHub
commit 4744d92c9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 78 additions and 35 deletions

View File

@ -56,6 +56,22 @@
"0xacd7275dcc7397adf479da0aa10e7adc0cbea8eb4f0d7f1fa6fc8af0c40d8eaf": {
"name": "Escrow",
"address": "0x257662a1866615f5c0E4A9D7633a3e317218e71A"
},
"0xefee7af745628c05176c41ac2b2405381b955e4e1adba0fa215725886952baa1": {
"name": "Arbitration",
"address": "0x9CA3431aC0841b77b08c7eaD74C3fca5dcEeCf5A"
},
"0xf5fd1b8de657b9575e8c060c28dc3408b227204bc6f4a6669ba47f69a6ada385": {
"name": "License",
"address": "0xB280d7dd9804C90B2466bB6da2cDfC77eA35120d"
},
"0xb6f7a024add470a4104ae7e6af00e64b5734bc5cfcfd27622523f31822b2b120": {
"name": "MetadataStore",
"address": "0x03450CD2DdfC8678B91EaCE1a81761597722F1cc"
},
"0xdf14773a44b2fa0ab93d7e6db5a13acdba12ed9d5d2e4a43f76364b122bc00ce": {
"name": "Escrow",
"address": "0xd477BD120F2E75b4b1f7cf7E85eEB1Af10B45619"
}
}
}

View File

@ -1,5 +1,5 @@
import { APPROVE_SUCCEEDED, APPROVE_FAILED, APPROVE_PRE_SUCCEEDED, GET_SNT_ALLOWANCE_SUCCEEDED, GET_TOKEN_ALLOWANCE_SUCCEEDED } from './constants';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {
error: '',
@ -46,6 +46,7 @@ function reducer(state = DEFAULT_STATE, action) {
tokenAllowance: action.allowance
}
};
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;
}

View File

@ -25,8 +25,7 @@ import {
CHECK_LICENSE_OWNER_SUCCEEDED
} from './constants';
import { fromTokenDecimals } from '../../utils/numbers';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {
escrows: [], arbitration: null, arbitrators: [], licenseOwner: false,
@ -150,6 +149,8 @@ function reducer(state = DEFAULT_STATE, action) {
error: ''
});
}
case PURGE_STATE:
return DEFAULT_STATE;
default:
return state;
}

View File

@ -12,7 +12,7 @@ import {
} from './constants';
import { States } from '../../utils/transaction';
import { escrowStatus } from './helpers';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
import merge from 'merge';
const DEFAULT_STATE = {
@ -205,6 +205,7 @@ function reducer(state = DEFAULT_STATE, action) {
releaseStatus: States.none,
rateStatus: States.none
};
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;
}

View File

@ -4,7 +4,7 @@ import {
CHECK_LICENSE_OWNER_SUCCEEDED, GET_LICENSE_OWNERS_SUCCCEDED, GET_LICENSE_OWNERS_FAILED, LOAD_PRICE_SUCCEEDED
} from './constants';
import { fromTokenDecimals } from '../../utils/numbers';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {
licenseOwner: false,
@ -69,6 +69,7 @@ function reducer(state = DEFAULT_STATE, action) {
...state,
licenseOwnersError: action.error
};
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;
}

View File

@ -6,7 +6,7 @@ import {
} from './constants';
import {USER_RATING_SUCCEEDED, CREATE_ESCROW_SUCCEEDED} from '../escrow/constants';
import { States } from '../../utils/transaction';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {
addOfferStatus: States.none,
@ -137,6 +137,8 @@ function reducer(state = DEFAULT_STATE, action) {
}
};
}
case PURGE_STATE:
return DEFAULT_STATE;
default:
return state;
}

View File

@ -1,5 +1,4 @@
import { INIT, UPDATE_BALANCES, UPDATE_BALANCE, GET_CONTACT_CODE, RESET_STATE, RESOLVE_ENS_NAME } from './constants';
import { PURGE } from 'redux-persist';
import { INIT, UPDATE_BALANCES, UPDATE_BALANCE, GET_CONTACT_CODE, RESET_STATE, RESOLVE_ENS_NAME, PURGE_STATE } from './constants';
export const init = () => ({ type: INIT });
export const resetState = () => ({ type: RESET_STATE });
@ -8,4 +7,7 @@ export const updateBalance = (symbol, address) => ({ type: UPDATE_BALANCE, symbo
export const getContactCode = () => ({type: GET_CONTACT_CODE});
export const resolveENSName = (ens) => ({type: RESOLVE_ENS_NAME, ens});
export const clearCache = () => ({type: PURGE});
export const clearCache = (cb) => {
return {type: PURGE_STATE, result: cb};
};

View File

@ -3,6 +3,7 @@ export const INIT_SUCCEEDED = 'NETWORK/INIT/SUCCEEDED';
export const INIT_FAILED = 'NETWORK/INIT/FAILED';
export const RESET_STATE = 'RESET_STATE';
export const PURGE_STATE = 'PURGE_STATE';
export const UPDATE_BALANCES = 'NETWORK/UPDATE_BALANCES';
export const UPDATE_BALANCE = 'NETWORK/UPDATE_BALANCE';

View File

@ -1,5 +1,5 @@
import {SET_CONTACT_INFO, SET_TRADE, SET_OFFER_ID} from './constants';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {
currencyQuantity: 0,
@ -24,6 +24,7 @@ function reducer(state = DEFAULT_STATE, action) {
currencyQuantity: action.currencyQuantity,
assetQuantity: action.assetQuantity
};
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;
}

View File

@ -7,7 +7,7 @@ import {
SET_CONTACT_INFO,
SET_ARBITRATOR
} from './constants';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {
asset: '',
@ -60,6 +60,7 @@ function reducer(state = DEFAULT_STATE, action) {
username: action.username,
statusContactCode: action.statusContactCode
};
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;
}

View File

@ -1,19 +1,23 @@
import { FETCH_PRICES_SUCCEEDED, FETCH_PRICES_FAILED } from './constants';
import {PURGE_STATE} from '../network/constants';
function reducer(state = {}, action) {
switch (action.type) {
case FETCH_PRICES_SUCCEEDED:
return {
...state,
...action.data
};
case FETCH_PRICES_FAILED:
return {
...state,
...{error: action.error}
};
default:
return state;
case FETCH_PRICES_SUCCEEDED:
return {
...state,
...action.data
};
case FETCH_PRICES_FAILED:
return {
...state,
...{error: action.error}
};
case PURGE_STATE:
return {};
default:
return state;
}
}

View File

@ -4,7 +4,7 @@ import {
INCLUDE_SIGNATURE_SUCCEEDED,
INCLUDE_SIGNATURE_FAILED
} from './constants';
import {RESET_STATE} from "../network/constants";
import {RESET_STATE, PURGE_STATE} from "../network/constants";
const DEFAULT_STATE = {message: null, type: null, escrowId: null, loading: false};
@ -38,6 +38,7 @@ function reducer(state = DEFAULT_STATE, action) {
loading: false
}
};
case PURGE_STATE:
case RESET_STATE: {
return DEFAULT_STATE;
}

View File

@ -1,25 +1,36 @@
import React from 'react';
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {Button, Col, Row} from "reactstrap";
import network from '../../features/network';
import {connect} from "react-redux";
import {withRouter} from "react-router-dom";
const Settings = ({resetState}) => (
<Row>
<Col xs="8" className="v-align-center text-right">
<Button color="secondary" onClick={resetState}>Reset cache</Button>
</Col>
</Row>
);
class Settings extends Component {
clearCache = () => {
this.props.clearCache();
setTimeout(() => {
window.location.reload();
}, 500);
};
render() {
return (<Row>
<Col xs="8" className="v-align-center text-right">
<Button color="secondary" onClick={this.clearCache}>Reset cache</Button>
</Col>
</Row>);
}
}
Settings.propTypes = {
resetState: PropTypes.func
clearCache: PropTypes.func,
history: PropTypes.object
};
export default connect(
null,
{
resetState: network.actions.resetState
clearCache: network.actions.clearCache
}
)(Settings);
)(withRouter(Settings));