Skip to content

Commit

Permalink
♻️ Update bookmark actions
Browse files Browse the repository at this point in the history
  • Loading branch information
massao committed May 10, 2019
1 parent 09543c3 commit d348430
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/actions/followedAccounts.js
@@ -1,29 +1,16 @@
import actionTypes from '../constants/actions';
import { getAccount } from '../utils/api/lsk/account';

export const followedAccountAdded = account => ({
data: account,
export const followedAccountAdded = ({ account, token = 'LSK' }) => ({
data: { account, token },
type: actionTypes.followedAccountAdded,
});

export const followedAccountUpdated = account => ({
data: account,
export const followedAccountUpdated = ({ account, token = 'LSK' }) => ({
data: { account, token },
type: actionTypes.followedAccountUpdated,
});

export const followedAccountRemoved = account => ({
data: account,
export const followedAccountRemoved = ({ address, token = 'LSK' }) => ({
data: { address, token },
type: actionTypes.followedAccountRemoved,
});

export const followedAccountFetchedAndUpdated = ({ account }) =>
(dispatch, getState) => {
const liskAPIClient = getState().peers.liskAPIClient;
getAccount(liskAPIClient, account.address).then((result) => {
if (result.balance !== account.balance || result.publicKey !== account.publicKey) {
account.balance = result.balance;
if (result.publicKey) account.publicKey = result.publicKey;
dispatch(followedAccountUpdated(account));
}
});
};

0 comments on commit d348430

Please sign in to comment.