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

Commit

Permalink
feat(users): use setUpUserProfile if there is a chance it is a new user
Browse files Browse the repository at this point in the history
  • Loading branch information
satello committed May 10, 2018
1 parent 91032e9 commit 7734223
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/resources/Disputes.js
Expand Up @@ -127,7 +127,7 @@ class Disputes {
const amountShift = event.args._amount.toNumber() const amountShift = event.args._amount.toNumber()
// juror won/lost tokens // juror won/lost tokens
if (address === account) { if (address === account) {
const userProfile = await this._StoreProviderInstance.getUserProfile( const userProfile = await this._StoreProviderInstance.setUpUserProfile(
account account
) )
const contractAddress = this._ArbitratorInstance.getContractAddress() const contractAddress = this._ArbitratorInstance.getContractAddress()
Expand Down
5 changes: 2 additions & 3 deletions src/resources/Notifications.js
Expand Up @@ -234,8 +234,7 @@ class Notifications {
*/ */
getUnreadStoredNotifications = async account => { getUnreadStoredNotifications = async account => {
this._requireStoreProvider() this._requireStoreProvider()

const profile = await this._StoreProviderInstance.setUpUserProfile(account)
const profile = await this._StoreProviderInstance.getUserProfile(account)
const currentArbitrator = this._ArbitratorInstance.getContractAddress() const currentArbitrator = this._ArbitratorInstance.getContractAddress()
// return notifications that are for current arbitrator and are unread // return notifications that are for current arbitrator and are unread
return _.filter( return _.filter(
Expand Down Expand Up @@ -605,7 +604,7 @@ class Notifications {


// If we have store provider fetch contracts and disputes from the store. // If we have store provider fetch contracts and disputes from the store.
if (this._StoreProviderInstance) { if (this._StoreProviderInstance) {
const userProfile = await this._StoreProviderInstance.getUserProfile( const userProfile = await this._StoreProviderInstance.setUpUserProfile(
account account
) )


Expand Down
14 changes: 7 additions & 7 deletions src/utils/StoreProviderWrapper.js
Expand Up @@ -172,7 +172,7 @@ class StoreProviderWrapper {
* @returns {number} The last block number. * @returns {number} The last block number.
*/ */
getLastBlock = async userAddress => { getLastBlock = async userAddress => {
const userProfile = await this.getUserProfile(userAddress) const userProfile = await this.setUpUserProfile(userAddress)


return userProfile.lastBlock || 0 return userProfile.lastBlock || 0
} }
Expand Down Expand Up @@ -229,10 +229,10 @@ class StoreProviderWrapper {
setUpUserProfile = async userAddress => { setUpUserProfile = async userAddress => {
let userProfile = await this.getUserProfile(userAddress) let userProfile = await this.getUserProfile(userAddress)
if (_.isNull(userProfile)) { if (_.isNull(userProfile)) {
this.updateUserProfile(userAddress, {}) const response = await this.updateUserProfile(userAddress, {})
userProfile = await this.queueReadRequest( if (response.status !== 201)
`${this._storeUri}/${userAddress}` throw new Error(errorConstants.REQUEST_FAILED(response.responseText))
) userProfile = response.body
} }


return userProfile return userProfile
Expand Down Expand Up @@ -329,7 +329,7 @@ class StoreProviderWrapper {
params params
) => { ) => {
const getBodyFn = async () => { const getBodyFn = async () => {
const userProfile = await this.getUserProfile(userAddress) const userProfile = await this.setUpUserProfile(userAddress)


const currentDisputeProfile = const currentDisputeProfile =
_.filter( _.filter(
Expand Down Expand Up @@ -438,7 +438,7 @@ class StoreProviderWrapper {
isRead = true isRead = true
) => { ) => {
const getBodyFn = async () => { const getBodyFn = async () => {
const userProfile = await this.getUserProfile(userAddress) const userProfile = await this.setUpUserProfile(userAddress)


const notificationIndex = await _.findIndex( const notificationIndex = await _.findIndex(
userProfile.notifications, userProfile.notifications,
Expand Down

0 comments on commit 7734223

Please sign in to comment.