import React from 'react'
import * as antd from 'antd'
import styles from './index.less'
import { CustomIcons, Like_button } from 'components'
import * as ycore from 'ycore'
import * as Icons from '@ant-design/icons'
import Icon from '@ant-design/icons'
import classnames from 'classnames'
import * as MICON from '@material-ui/icons'
const { Meta } = antd.Card
// Set default by configuration
const emptyPayload = {
user: 'Post Empty',
ago: 'This Post is empty',
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
content: 'Empty',
}
class PostCard extends React.PureComponent {
constructor(props) {
super(props),
(this.state = {
FadeIN: true,
postPinned: this.props.payload.is_post_pinned,
postSaved: this.props.payload.is_post_saved,
postReported: this.props.payload.is_post_reported,
postBoosted: this.props.payload.is_post_boosted,
ReportIgnore: false,
})
}
renderPostPlayer(payload) {
const ident = payload
if (ident.includes('.mp4')) {
return (
)
}
if (ident.includes('.webm')) {
return (
)
}
if (ident.includes('.mp3')) {
return (
)
}
if (ident.includes('.ogg')) {
return (
)
} else {
return
}
}
goToPost(postID) {
localStorage.setItem('p_back_uid', postID)
const payload = { post_id: postID }
ycore.comty_post.get((err, res) => {
if (err) {
return false
}
ycore.SecondarySwap.openPost(res)
}, payload)
}
render() {
const { payload, customActions } = this.props
const ActShowMode = ycore.AppSettings.auto_hide_postbar
const {
id,
post_time,
postText,
postFile,
publisher,
post_likes,
is_post_pinned,
is_liked,
post_comments,
} = payload || emptyPayload
const handlePostActions = {
delete: post_id => {
const payload = { post_id: post_id }
ycore.comty_post.delete((err, res) => {
if (err) {
return false
}
ycore.FeedHandler.killByID(post_id)
}, payload)
},
save: post_id => {
const payload = { post_id: post_id }
ycore.comty_post.save((err, res) => {
if (err) {
return false
}
if (this.state.postSaved == false) {
ycore.notify.success('Post Saved')
this.setState({ postSaved: true })
return
} else {
ycore.notify.info('Removed from Saved')
this.setState({ postSaved: false })
}
}, payload)
},
report: post_id => {
ycore.app_modals.report_post(post_id)
},
boost: post_id => {
const payload = { post_id: post_id }
ycore.comty_post.__boost((err, res) => {
if (err) {
return false
}
if (this.state.postBoosted == false) {
ycore.notify.success('Post Boosted')
this.setState({ postBoosted: true })
return
} else {
ycore.notify.info('Post Unboosted')
this.setState({ postBoosted: false })
}
}, payload)
},
}
const defaultActions = [
The content may be inappropriate or compromising