fix ReturnValueFromMap

This commit is contained in:
srgooglo 2020-03-25 03:59:14 +01:00
parent 7ff47419fb
commit 44b186c3af
2 changed files with 14 additions and 9 deletions

View File

@ -121,15 +121,14 @@ export function uploadFile(file) {
* @return {string} Boolean value
*/
export function ReturnValueFromMap(payload) {
if (!payload) {
return false
}
if (!payload) return false
const { data, key } = payload
try {
const Ite = payload.data.map(item => {
return item.key === payload.key ? item.value : null
const a = data.map(item => {
return item.key === key ? item.value : null
})
const fr = Ite.filter(Boolean)
return fr.toString()
const b = a.filter(Boolean)
return b.toString()
} catch (error) {
return false
}

View File

@ -172,7 +172,13 @@ class PostCreator extends React.PureComponent {
return false
}
const id_temp_parse = JSON.parse(res)['data'].id
if (ycore.ReturnValueFromMap({ data: post_options, key: 'pro_boost' })) {
const pro_boost_val = ycore.ReturnValueFromMap({ data: post_options, key: 'pro_boost' })
const allow_comments_val = ycore.ReturnValueFromMap({ data: post_options, key: 'allow_comments' })
ycore.yconsole.log(`pro_boost => ${pro_boost_val} | allow_comments => ${allow_comments_val}`)
if (pro_boost_val) {
ycore.yconsole.log(`Boosting post with ID => ${id_temp_parse}`)
ycore.comty_post.__boost(
(err, res) => {
@ -182,7 +188,7 @@ class PostCreator extends React.PureComponent {
)
}
if (
ycore.ReturnValueFromMap({ data: post_options, key: 'allow_comments' })
!allow_comments_val
) {
ycore.yconsole.log(`Disabling comments with ID => ${id_temp_parse}`)
ycore.comty_post.__disableComments(