Skip to content
Permalink
Browse files

feat: new endpoint for mark notification read

  • Loading branch information...
satello committed Jun 20, 2018
1 parent 430e494 commit 1b46d8acfac356958752029ffa413a598f605f56
Showing with 10 additions and 19 deletions.
  1. +1 −1 src/contracts/implementations/arbitrator/KlerosPOC.js
  2. +9 −18 src/utils/StoreProviderWrapper.js
@@ -683,7 +683,7 @@ class KlerosPOC extends ContractImplementation {
netPNK += event.args._amount.toNumber()
}

return netPNK
return this._Web3Wrapper.fromWei(netPNK, 'ether')
}

/**
@@ -433,30 +433,21 @@ class StoreProviderWrapper {
logIndex,
isRead = true
) => {
const getBodyFn = async () => {
const userProfile = await this.newUserProfile(userAddress)

const notificationIndex = await _.findIndex(
userProfile.notifications,
notification =>
notification.txHash === txHash && notification.logIndex === logIndex
const getBodyFn = () =>
new Promise(resolve =>
resolve(
JSON.stringify({
logIndex,
isRead
})
)
)

if (_.isNull(notificationIndex))
throw new Error(errorConstants.NOTIFICATION_NOT_FOUND(txHash))

userProfile.notifications[notificationIndex].read = isRead
delete userProfile._id
delete userProfile.created_at
return JSON.stringify(userProfile)
}

const result = await this.queueWriteRequest(
getBodyFn,
'POST',
`${this._storeUri}/${userAddress}`
`${this._storeUri}/${userAddress}/notifications/${txHash}/read`
)

return result.body.notifications
}
}

0 comments on commit 1b46d8a

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