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 * @return {string} Boolean value
*/ */
export function ReturnValueFromMap(payload) { export function ReturnValueFromMap(payload) {
if (!payload) { if (!payload) return false
return false const { data, key } = payload
}
try { try {
const Ite = payload.data.map(item => { const a = data.map(item => {
return item.key === payload.key ? item.value : null return item.key === key ? item.value : null
}) })
const fr = Ite.filter(Boolean) const b = a.filter(Boolean)
return fr.toString() return b.toString()
} catch (error) { } catch (error) {
return false return false
} }

View File

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