Skip to content

Commit

Permalink
add Async to fix issues with steem-js update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sambillingham committed Jan 27, 2018
1 parent 0c9e925 commit 562570d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 4 additions & 6 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// import * as util from './modules/util.js'
import * as ui from './modules/uiActions.js'
import * as steem from './modules/steemActions.js'
import * as steemActions from './modules/steemActions.js'

export let mixer;

STEEM_SERVER = 'https://api.steemit.com';

const STEEM_SERVER = 'https://api.steemit.com'
// UI CONTROLS
ui.initUiActions();

Expand All @@ -28,5 +26,5 @@ $(document).ready(() => {

//setups

steem.getGlobalProps(STEEM_SERVER)
.then(steem.checkForUsersAndSearch())
steemActions.getGlobalProps(STEEM_SERVER)
.then(steemActions.checkForUsersAndSearch())
17 changes: 10 additions & 7 deletions js/modules/steemActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function checkForUsersAndSearch(){
export function addUsers(users){
var sort = ($('.mixitup-control-active').length) ? $('.mixitup-control-active').data('btn-sort') : false
getAccounts(users)
.then(data => proccessData(data))
.then(data => proccessData(data) )
.then(data => displayAccounts(data, sort))
}

Expand Down Expand Up @@ -99,16 +99,19 @@ export function displayAccounts(newAccounts, sortValue ){
}

export function getGlobalProps(server){
steem.api.setOptions({ url: server });
return steem.api.getDynamicGlobalProperties((err, result) => {
totalVestingShares = result.total_vesting_shares;
totalVestingFundSteem = result.total_vesting_fund_steem;
return new Promise((resolve, reject) => {
steem.api.setOptions({ url: server });
steem.api.getDynamicGlobalProperties((err, result) => {
totalVestingShares = result.total_vesting_shares;
totalVestingFundSteem = result.total_vesting_fund_steem;
resolve()
})
})
}


export function getAccounts(accountNames){
return steem.api.getAccounts(accountNames, (err, response) => response )
return steem.api.getAccountsAsync(accountNames)
};

export function proccessData(accounts){
Expand Down Expand Up @@ -154,7 +157,7 @@ export function proccessData(accounts){
});


let followerAndFollowingCount = accountsData.map( user => steem.api.getFollowCount(user.name))
let followerAndFollowingCount = accountsData.map( user => steem.api.getFollowCountAsync(user.name))

Promise.all(followerAndFollowingCount)
.then(data => {
Expand Down

0 comments on commit 562570d

Please sign in to comment.