Skip to content
Permalink
Browse files

feat(users): use setUpUserProfile if there is a chance it is a new user

  • Loading branch information...
satello committed May 10, 2018
1 parent 91032e9 commit 7734223755706c3771e622e7f679ef2f4dacb0e3
Showing with 10 additions and 11 deletions.
  1. +1 −1 src/resources/Disputes.js
  2. +2 −3 src/resources/Notifications.js
  3. +7 −7 src/utils/StoreProviderWrapper.js
@@ -127,7 +127,7 @@ class Disputes {
const amountShift = event.args._amount.toNumber()
// juror won/lost tokens
if (address === account) {
const userProfile = await this._StoreProviderInstance.getUserProfile(
const userProfile = await this._StoreProviderInstance.setUpUserProfile(
account
)
const contractAddress = this._ArbitratorInstance.getContractAddress()
@@ -234,8 +234,7 @@ class Notifications {
*/
getUnreadStoredNotifications = async account => {
this._requireStoreProvider()

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

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

@@ -172,7 +172,7 @@ class StoreProviderWrapper {
* @returns {number} The last block number.
*/
getLastBlock = async userAddress => {
const userProfile = await this.getUserProfile(userAddress)
const userProfile = await this.setUpUserProfile(userAddress)

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

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

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

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

0 comments on commit 7734223

Please sign in to comment.
You can’t perform that action at this time.