diff --git a/src/modules/Dapps/Dapps.reducer.js b/src/modules/Dapps/Dapps.reducer.js index 119bee7..dba9995 100644 --- a/src/modules/Dapps/Dapps.reducer.js +++ b/src/modules/Dapps/Dapps.reducer.js @@ -48,11 +48,13 @@ class DappsState { } } - // this.items.sort((a, b) => { - // return new Date(b.dateAdded).getTime() - new Date(a.dateAdded).getTime() - // }) this.hasMore = addedItems !== 0 } + + cloneWeakItems() { + this.items = [...this.items] + return this + } } export const onFinishFetchAllDappsAction = dapps => ({ @@ -146,36 +148,6 @@ export const fetchAllDappsAction = () => { } } -// export const fetchHighestRankedAction = () => { -// return dispatch => { -// dispatch(onStartFetchHighestRankedAction()) -// setTimeout(() => { -// const result = hardcodedDapps -// .sort((a, b) => { -// return b.sntValue - a.sntValue -// }) -// .slice(0, 50) -// dispatch(onFinishFetchHighestRankedAction(result)) -// }, 100) -// } -// } - -// export const fetchRecentlyAddedAction = () => { -// return dispatch => { -// dispatch(onStartFetchRecentlyAddedAction()) -// setTimeout(() => { -// const result = hardcodedDapps -// .sort((a, b) => { -// return ( -// new Date().getTime(b.dateAdded) - new Date(a.dateAdded).getTime() -// ) -// }) -// .slice(0, 20) -// dispatch(onFinishFetchRecentlyAddedAction(result)) -// }, 100) -// } -// } - export const fetchByCategoryAction = category => { return async (dispatch, getState) => { dispatch(onStartFetchByCategoryAction(category)) @@ -229,7 +201,7 @@ const onFinishFetchRecentlyAdded = (state, payload) => { const onStartFetchByCategory = (state, payload) => { const dappsCategoryMap = new Map() state.dappsCategoryMap.forEach((dappState, category) => { - dappsCategoryMap.set(category, dappState) + dappsCategoryMap.set(category, dappState.cloneWeakItems()) if (category === payload) dappState.setFetched(true) }) return Object.assign({}, state, { @@ -269,7 +241,7 @@ const onUpdateDappData = (state, dapp) => { let update = false state.dappsCategoryMap.forEach((dappState, category_) => { - dappsCategoryMap.set(category_, dappState) + dappsCategoryMap.set(category_, dappState.cloneWeakItems()) }) for (let i = 0; i < dapps.length; i += 1) { @@ -301,7 +273,6 @@ const onUpdateDappData = (state, dapp) => { return target.sntValue < dappItem.sntValue }) } else { - // update hightestRanked, recentlyAdded, dappsCategoryMap for (let i = 0; i < highestRanked.length; i += 1) { if (highestRanked[i].id === dapp.id) { highestRanked[i] = dapp diff --git a/src/modules/Vote/Vote.jsx b/src/modules/Vote/Vote.jsx index 932e945..d25d4ce 100644 --- a/src/modules/Vote/Vote.jsx +++ b/src/modules/Vote/Vote.jsx @@ -140,7 +140,7 @@ class Vote extends Component { )} {!isUpvote && afterVoteRating !== null && ( - {`${(dapp.sntValue + afterVoteRating).toLocaleString()} ↓`} + {`${(dapp.sntValue - afterVoteRating).toLocaleString()} ↓`} )}