Skip to content

Commit

Permalink
Merge pull request #370 from LiskHQ/365-remove-toasters
Browse files Browse the repository at this point in the history
Remove toasters - Closes #365
  • Loading branch information
gina contrino authored Feb 16, 2018
2 parents de444eb + c63d536 commit 459988c
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 284 deletions.
6 changes: 0 additions & 6 deletions i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"Add vote to": "Add vote to",
"Additional fee": "Additional fee",
"Address": "Address",
"Address copied to clipboard": "Address copied to clipboard",
"Address timeout in": "Address timeout in",
"Advanced features": "Advanced features",
"All": "All",
Expand Down Expand Up @@ -41,7 +40,6 @@
"Copied!": "Copied!",
"Copy": "Copy",
"Copy Transaction ID to clipboard": "Copy Transaction ID to clipboard",
"Copy address to clipboard": "Copy address to clipboard",
"Create your Lisk ID": "Create your Lisk ID",
"Current version is up-to-date.": "Current version is up-to-date.",
"Currently we speaking english and german.": "Currently we speaking english and german.",
Expand Down Expand Up @@ -110,8 +108,6 @@
"Mainnet": "Mainnet",
"Maximum of 101 votes in total": "Maximum of 101 votes in total",
"Maximum of {{maxcount}} votes at a time": "Maximum of {{maxcount}} votes at a time",
"Maximum of {{n}} votes exceeded.": "Maximum of {{n}} votes exceeded.",
"Maximum of {{n}} votes in one transaction exceeded.": "Maximum of {{n}} votes in one transaction exceeded.",
"Menu": "Menu",
"Minimize": "Minimize",
"Multisignature Creation": "Multisignature Creation",
Expand Down Expand Up @@ -140,7 +136,6 @@
"Please click Next, then move around your mouse randomly to generate a random passphrase.": "Please click Next, then move around your mouse randomly to generate a random passphrase.",
"Please go back and check your passphrase again.": "Please go back and check your passphrase again.",
"Please keep it safe!": "Please keep it safe!",
"Press #{key} to copy": "Press #{key} to copy",
"Press ↲ enter to search": "Press ↲ enter to search",
"Price data currently not available": "Price data currently not available",
"Processing delegate names: ": "Processing delegate names: ",
Expand All @@ -149,7 +144,6 @@
"Quickly send and request LSK token": "Quickly send and request LSK token",
"Quit": "Quit",
"Rank": "Rank",
"Receive LSK": "Receive LSK",
"Recipient": "Recipient",
"Redo": "Redo",
"Register": "Register",
Expand Down
5 changes: 0 additions & 5 deletions src/components/dialog/dialogs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import i18next from 'i18next';
import ReceiveDialog from '../receiveDialog';
import RegisterDelegate from '../registerDelegate';
import SavedAccounts from '../savedAccounts';
import savedAccountsTheme from '../savedAccounts/modalTheme.css';
Expand All @@ -24,10 +23,6 @@ export default () => ({
title: i18next.t('Vote for delegates'),
component: VoteDialog,
},
receive: {
title: i18next.t('Receive LSK'),
component: ReceiveDialog,
},
'saved-accounts': {
component: SavedAccounts,
theme: savedAccountsTheme,
Expand Down
19 changes: 0 additions & 19 deletions src/components/receiveDialog/index.js

This file was deleted.

61 changes: 0 additions & 61 deletions src/components/receiveDialog/index.test.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/components/receiveDialog/receiveDialog.css

This file was deleted.

46 changes: 0 additions & 46 deletions src/components/receiveDialog/receiveDialog.js

This file was deleted.

54 changes: 0 additions & 54 deletions src/components/receiveDialog/receiveDialog.test.js

This file was deleted.

30 changes: 0 additions & 30 deletions src/store/middlewares/voting.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import i18next from 'i18next';

import { errorToastDisplayed } from '../../actions/toaster';
import { getDelegate } from '../../utils/api/delegate';
import { voteLookupStatusUpdated, voteToggled } from '../../actions/voting';
import actionTypes from '../../constants/actions';
import votingConst from '../../constants/voting';
import { getTotalVotesCount } from './../../utils/voting';

const updateLookupStatus = (store, list, username) => {
store.dispatch(voteLookupStatusUpdated({
Expand Down Expand Up @@ -56,34 +51,9 @@ const lookupDelegatesFromUrl = (store, action) => {
}
};

const checkVoteLimits = (store, action) => {
const { votes } = store.getState().voting;
const currentVote = votes[action.data.username] || { unconfirmed: true, confirmed: false };

const newVoteCount = Object.keys(votes).filter(
key => votes[key].confirmed !== votes[key].unconfirmed).length;
if (newVoteCount === votingConst.maxCountOfVotesInOneTurn + 1 &&
currentVote.unconfirmed !== currentVote.confirmed) {
const label = i18next.t('Maximum of {{n}} votes in one transaction exceeded.', { n: votingConst.maxCountOfVotesInOneTurn });
const newAction = errorToastDisplayed({ label });
store.dispatch(newAction);
}

const voteCount = getTotalVotesCount(votes);
if (voteCount === votingConst.maxCountOfVotes + 1 &&
currentVote.unconfirmed !== currentVote.confirmed) {
const label = i18next.t('Maximum of {{n}} votes exceeded.', { n: votingConst.maxCountOfVotes });
const newAction = errorToastDisplayed({ label });
store.dispatch(newAction);
}
};

const votingMiddleware = store => next => (action) => {
next(action);
switch (action.type) {
case actionTypes.voteToggled:
checkVoteLimits(store, action);
break;
case actionTypes.votesAdded:
lookupDelegatesFromUrl(store, action);
break;
Expand Down
56 changes: 0 additions & 56 deletions src/store/middlewares/voting.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { expect } from 'chai';
import { spy, stub, mock } from 'sinon';


import { errorToastDisplayed } from '../../actions/toaster';
import { voteLookupStatusUpdated } from '../../actions/voting';
import * as delegateApi from '../../utils/api/delegate';
import actionTypes from '../../constants/actions';
Expand All @@ -12,8 +10,6 @@ import votingConst from '../../constants/voting';
describe('voting middleware', () => {
let store;
let next;
const label = `Maximum of ${votingConst.maxCountOfVotesInOneTurn} votes in one transaction exceeded.`;
const label2 = `Maximum of ${votingConst.maxCountOfVotes} votes exceeded.`;

const generateNVotes = (n, vote) => (
[...Array(n)].map((item, i) => i).reduce(
Expand Down Expand Up @@ -55,58 +51,6 @@ describe('voting middleware', () => {
expect(next).to.have.been.calledWith(givenAction);
});

describe('on voteToggled action', () => {
it('should dispatch errorToastDisplayed if 34 new votes and new vote unconfirmed !== confirmed ', () => {
const givenAction = {
type: actionTypes.voteToggled,
data: {
username: 'test',
},
};
middleware(store)(next)(givenAction);
expect(store.dispatch).to.have.been.calledWith(errorToastDisplayed({ label }));
});

it('should not dispatch errorToastDisplayed if 34 new votes and new vote unconfirmed === confirmed ', () => {
const givenAction = {
type: actionTypes.voteToggled,
data: {
username: 'test2',
},
};
middleware(store)(next)(givenAction);
expect(store.dispatch).to.not.have.been.calledWith(errorToastDisplayed({ label }));
});

it('should dispatch errorToastDisplayed if 102 votes and new vote unconfirmed !== confirmed ', () => {
initStoreWithNVotes(
votingConst.maxCountOfVotes + 1,
{ confirmed: true, unconfirmed: true });
const givenAction = {
type: actionTypes.voteToggled,
data: {
username: 'test',
},
};
middleware(store)(next)(givenAction);
expect(store.dispatch).to.have.been.calledWith(errorToastDisplayed({ label: label2 }));
});

it('should not dispatch errorToastDisplayed if 102 votes and new vote unconfirmed === confirmed ', () => {
initStoreWithNVotes(
votingConst.maxCountOfVotes + 1,
{ confirmed: true, unconfirmed: true });
const givenAction = {
type: actionTypes.voteToggled,
data: {
username: 'genesis_42',
},
};
middleware(store)(next)(givenAction);
expect(store.dispatch).to.not.have.been.calledWith(errorToastDisplayed({ label: label2 }));
});
});

describe('on votesAdded action', () => {
const state = {
voting: {
Expand Down

0 comments on commit 459988c

Please sign in to comment.