From 5c8dcb1d8f3452709c297d6cdeb9e52683eae288 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 22 Mar 2019 18:27:47 +0400 Subject: [PATCH] move token-related localstorage logic to toknes folder --- package-lock.json | 5 +++++ package.json | 1 + src/components/Table/index.jsx | 4 ++-- src/logic/tokens/store/actions/enableToken.js | 8 +++++++- src/logic/tokens/store/actions/fetchTokens.js | 2 +- src/logic/tokens/store/reducer/tokens.js | 2 +- .../tokens/utils/activeTokensStorage.js} | 0 src/routes/safe/component/Balances/Tokens/index.jsx | 1 + src/routes/safe/component/Balances/dataFetcher.js | 1 - src/test/tokens.dom.enabling.test.js | 2 +- 10 files changed, 19 insertions(+), 7 deletions(-) rename src/{utils/localStorage/tokens.js => logic/tokens/utils/activeTokensStorage.js} (100%) diff --git a/package-lock.json b/package-lock.json index dafc942a..122b85f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22452,6 +22452,11 @@ "html-element-attributes": "^1.0.0" } }, + "react-infinite-scroll-component": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/react-infinite-scroll-component/-/react-infinite-scroll-component-4.5.2.tgz", + "integrity": "sha512-fkCOsAYDx0IHv7pTl9BzSTlNoaFccDzJ3gi2qNgp/D2GxKZKhGwDxqOnZyvMo5e5FhniQ9yaXsTxh/xZg8LuFQ==" + }, "react-input-autosize": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/react-input-autosize/-/react-input-autosize-2.2.1.tgz", diff --git a/package.json b/package.json index c0941453..74e0595c 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "react-dom": "^16.4.0", "react-final-form": "^4.1.0", "react-hot-loader": "^4.8.0", + "react-infinite-scroll-component": "^4.5.2", "react-redux": "^6.0.1", "react-router-dom": "^4.3.1", "recompose": "^0.30.0", diff --git a/src/components/Table/index.jsx b/src/components/Table/index.jsx index 3941dfc7..e0069158 100644 --- a/src/components/Table/index.jsx +++ b/src/components/Table/index.jsx @@ -94,8 +94,8 @@ class GnoTable extends React.Component, State> { this.setState({ page }) } - handleChangeRowsPerPage = (event: SyntheticInputEvent) => { - const rowsPerPage = Number(event.target.value) + handleChangeRowsPerPage = (e: SyntheticInputEvent) => { + const rowsPerPage = Number(e.target.value) this.setState({ rowsPerPage }) } diff --git a/src/logic/tokens/store/actions/enableToken.js b/src/logic/tokens/store/actions/enableToken.js index b8365390..6d4d4fdb 100644 --- a/src/logic/tokens/store/actions/enableToken.js +++ b/src/logic/tokens/store/actions/enableToken.js @@ -9,4 +9,10 @@ const enableToken = createAction(ENABLE_TOKEN, (safeAddress: string, token: Toke address: token.get('address'), })) -export default enableToken +const setTokenEnabled = (safeAddress: string, token: Token) => (dispatch: ReduxDispatch) => { + dispatch(enableToken(safeAddress, token)) + + +} + +export default setTokenEnabled diff --git a/src/logic/tokens/store/actions/fetchTokens.js b/src/logic/tokens/store/actions/fetchTokens.js index bf3bd781..4d5af3c8 100644 --- a/src/logic/tokens/store/actions/fetchTokens.js +++ b/src/logic/tokens/store/actions/fetchTokens.js @@ -8,7 +8,7 @@ import { getWeb3 } from '~/logic/wallets/getWeb3' import { type GlobalState } from '~/store/index' import { makeToken, type Token, type TokenProps } from '~/logic/tokens/store/model/token' import { ensureOnce } from '~/utils/singleton' -import { getActiveTokenAddresses, getTokens } from '~/utils/localStorage/tokens' +import { getActiveTokenAddresses, getTokens } from '~/logic/tokens/utils/activeTokensStorage' import { getSafeEthToken } from '~/utils/tokens' import { enhancedFetch } from '~/utils/fetch' import addTokens from './addTokens' diff --git a/src/logic/tokens/store/reducer/tokens.js b/src/logic/tokens/store/reducer/tokens.js index 64756527..50c654a1 100644 --- a/src/logic/tokens/store/reducer/tokens.js +++ b/src/logic/tokens/store/reducer/tokens.js @@ -12,7 +12,7 @@ import { getActiveTokenAddresses, setToken, removeTokenFromStorage, -} from '~/utils/localStorage/tokens' +} from '~/logic/tokens/utils/activeTokensStorage' import { ensureOnce } from '~/utils/singleton' import { calculateActiveErc20TokensFrom } from '~/utils/tokens' diff --git a/src/utils/localStorage/tokens.js b/src/logic/tokens/utils/activeTokensStorage.js similarity index 100% rename from src/utils/localStorage/tokens.js rename to src/logic/tokens/utils/activeTokensStorage.js diff --git a/src/routes/safe/component/Balances/Tokens/index.jsx b/src/routes/safe/component/Balances/Tokens/index.jsx index 33d56e5d..db685bf7 100644 --- a/src/routes/safe/component/Balances/Tokens/index.jsx +++ b/src/routes/safe/component/Balances/Tokens/index.jsx @@ -4,6 +4,7 @@ import { connect } from 'react-redux' import { List } from 'immutable' import classNames from 'classnames/bind' import SearchBar from 'material-ui-search-bar' +import InfiniteScroll from 'react-infinite-scroll-component' import { withStyles } from '@material-ui/core/styles' import MuiList from '@material-ui/core/List' import Img from '~/components/layout/Img' diff --git a/src/routes/safe/component/Balances/dataFetcher.js b/src/routes/safe/component/Balances/dataFetcher.js index 31e7fe8a..f879c691 100644 --- a/src/routes/safe/component/Balances/dataFetcher.js +++ b/src/routes/safe/component/Balances/dataFetcher.js @@ -26,7 +26,6 @@ export const getBalanceData = (activeTokens: List): Array => return Array.from(rows) } - export const generateColumns = () => { const assetRow: Column = { id: BALANCE_TABLE_ASSET_ID, diff --git a/src/test/tokens.dom.enabling.test.js b/src/test/tokens.dom.enabling.test.js index 27b634f5..0dcc9635 100644 --- a/src/test/tokens.dom.enabling.test.js +++ b/src/test/tokens.dom.enabling.test.js @@ -11,7 +11,7 @@ import { travelToTokens } from '~/test/builder/safe.dom.utils' import { sleep } from '~/utils/timer' import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps' import { tokenListSelector, activeTokensSelector } from '~/logic/tokens/store/selectors' -import { getActiveTokenAddresses } from '~/utils/localStorage/tokens' +import { getActiveTokenAddresses } from '~/logic/tokens/utils/activeTokensStorage' import { enableFirstToken, testToken } from '~/test/builder/tokens.dom.utils' import * as fetchTokensModule from '~/logic/tokens/store/actions/fetchTokens' import * as enhancedFetchModule from '~/utils/fetch'