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

Commit

Permalink
new chain: show only snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Jan 3, 2017
1 parent 5b2c049 commit 6ab2360
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 67 deletions.
6 changes: 3 additions & 3 deletions js/src/redux/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ import SignerMiddleware from './providers/signerMiddleware';

import statusMiddleware from '~/views/Status/middleware';
import CertificationsMiddleware from './providers/certifications/middleware';
import StatusMiddleware from './providers/statusMiddleware';
import ChainMiddleware from './providers/chainMiddleware';

export default function (api, browserHistory) {
const errors = new ErrorsMiddleware();
const signer = new SignerMiddleware(api);
const settings = new SettingsMiddleware();
const status = statusMiddleware();
const certifications = new CertificationsMiddleware();
const status2 = new StatusMiddleware();
const routeMiddleware = routerMiddleware(browserHistory);
const chain = new ChainMiddleware();

const middleware = [
settings.toMiddleware(),
signer.toMiddleware(),
errors.toMiddleware(),
certifications.toMiddleware(),
status2.toMiddleware()
chain.toMiddleware()
];

return middleware.concat(status, routeMiddleware, thunk);
Expand Down
4 changes: 0 additions & 4 deletions js/src/redux/providers/certifications/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

export const clearCertifiers = () => ({
type: 'clearCertifiers'
});

export const fetchCertifiers = () => ({
type: 'fetchCertifiers'
});
Expand Down
2 changes: 1 addition & 1 deletion js/src/redux/providers/certifications/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { uniq, range, debounce } from 'lodash';
import CertifierABI from '~/contracts/abi/certifier.json';
import Contract from '~/api/contract';
import Contracts from '~/contracts';
import { clearCertifiers, addCertification, removeCertification } from './actions';
import { addCertification, removeCertification } from './actions';

// TODO: move this to a more general place
const updatableFilter = (api, onFilter) => {
Expand Down
4 changes: 0 additions & 4 deletions js/src/redux/providers/certifications/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,5 @@ export default (state = initialState, action) => {
return { ...state, [address]: newCertifications };
}

if (action.type === 'clearCertifiers') {
return {};
}

return state;
};
38 changes: 38 additions & 0 deletions js/src/redux/providers/chainMiddleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import { showSnackbar } from './snackbarActions';

export default class ChainMiddleware {
toMiddleware () {
return (store) => (next) => (action) => {
if (action.type === 'statusCollection') {
const { collection } = action;

if (collection && collection.netChain) {
const chain = collection.netChain;
const { nodeStatus } = store.getState();

if (chain !== nodeStatus.netChain) {
showSnackbar(`Switched to ${chain}. Please reload the page.`, 3000);
}
}
}

next(action);
};
}
}
55 changes: 0 additions & 55 deletions js/src/redux/providers/statusMiddleware.js

This file was deleted.

0 comments on commit 6ab2360

Please sign in to comment.