Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #866 from swarmcity/bug_fixing
Browse files Browse the repository at this point in the history
Bug fixing
  • Loading branch information
xardass authored Nov 28, 2018
2 parents f126978 + 932a954 commit 86f82b0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/redux/app-reducers.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
balance: {},
hashtagList: [],
visitedHashtags: {},
fetching: {},
hashtags: {},
current: {},
Expand Down Expand Up @@ -313,6 +314,13 @@
}
}
}
case 'ADD_VISITED_HASHTAG': {
return deepmerge(state, {
visitedHashtags: {
[action.hashtag.hashtagAddress]: action.hashtag
}
})
}
default: {
return state
}
Expand Down
1 change: 1 addition & 0 deletions src/redux/app-selectors.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
},
confirmedTx: (state) => state.confirmedTx,
hashtagList: (state) => state.hashtagList,
visitedHashtags: (state) => state.visitedHashtags,
address: (state) => state.publicKey,
username: (state) => state.username,
language: (state) => state.language,
Expand Down
3 changes: 2 additions & 1 deletion src/redux/sagas/handleReplyItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
// Step 1. Store the reply info
console.log('Handling ReplyEvent', event)
const { itemHash, replyMetadataHash, provider: providerAddress } = event.returnValues
const { address: hashtagAddress } = event
// Protection against calling toLowerCase() on undefined variables
const hashtagAddress = event.address ? event.address.toLowerCase() : event.address
const reply = {
blockNumber: event.blockNumber,
providerAddress,
Expand Down
4 changes: 3 additions & 1 deletion src/redux/sagas/hashtag-saga.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
hashtagMetadataHash: await hashtagContract.methods.hashtagMetadataHash().call(),
hashtagFee: parseInt(await hashtagContract.methods.hashtagFee().call()),
deployBlock: deployBlock || 8149489,
address: hashtagContract._address
address: hashtagContract._address,
hashtagAddress: hashtagContract._address
}
}

Expand Down Expand Up @@ -157,6 +158,7 @@
// - deployBlock() -> deployBlock
const hashtagContractData = yield call(getHashtagContractData, hashtagContract)
yield put({ type: 'UPDATE_NEWHASHTAG', hashtagAddress, data: hashtagContractData });
yield put({ type: 'ADD_VISITED_HASHTAG', hashtag: hashtagContractData })

// Step 2A. Resolve hashtagMetadata with IPFS
// - ipfs.cat(hashtagMetadata) -> description
Expand Down
13 changes: 12 additions & 1 deletion src/redux/sagas/hashtagList-saga.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@
if (!hashtagList.length) {
hashtagList = yield call(getHashtagList)
}
const reputationsObj = yield call(getReputationFromHashtags, hashtagList, address)

// Append the visited hashtags and remove duplicates
// visitedHashtags is an object
const visitedHashtags = yield select(selectors.visitedHashtags)
const uniqueHashtags = visitedHashtags
hashtagList.forEach(hashtag => {
uniqueHashtags[hashtag.hashtagAddress] = hashtag
})
const uniqueHashtagList = Object.values(uniqueHashtags)

// Get reputation for all hashtags in the list
const reputationsObj = yield call(getReputationFromHashtags, uniqueHashtagList, address)
yield put({ type: 'UPDATE_REPUTATION', address, reputationsObj });
} catch (e) {
console.error(`Error fetching user's reputation`, e)
Expand Down
5 changes: 4 additions & 1 deletion src/redux/sagas/router-saga.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
const path = window.location.pathname
// [0 / [1] / [2] / [3]
// path = /hashtag/0xCeb...fE/0x2342tds
const [, pageName, hashtag, item] = path.split('/')
let [, pageName, hashtag, item] = path.split('/')

const params = parseSearch()

Expand Down Expand Up @@ -71,6 +71,9 @@
|| pageName === 'new-request'
) {
if (hashtag && hashtag !== _hashtag) {
// Prevent inconsistencies with address with/without checksum case
// This parameter is entered by the user
hashtag = hashtag.toLowerCase()
yield put({ type: 'GET_HASHTAG', hashtag })
yield put({ type: 'CURRENT_HASHTAG', hashtag })
_hashtag = hashtag;
Expand Down

0 comments on commit 86f82b0

Please sign in to comment.