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 = [
, 0 ? true : false}> this.goToPost(id)} /> , ] const actions = customActions || defaultActions const MoreMenu = ( {ycore.IsThisPost.owner(publisher.id) ? ( handlePostActions.delete(id)} key="remove_post" > Remove post ) : null} {ycore.IsThisPost.owner(publisher.id) ? ( ycore.IsThisUser.pro(publisher.id) ? ( handlePostActions.boost(id)} key="boost_post" > {' '} {this.state.postBoosted ? 'Unboost' : 'Boost'} ) : null ) : null} {ycore.IsThisPost.owner(publisher.id) ?
: null} handlePostActions.save(id)} key="save_post" > {' '} {this.state.postSaved ? 'Unsave post' : 'Save Post'} {this.state.postReported? null: handlePostActions.report(id)} key="report_post" > Report post }
) return (
this.goToPost(id)} hoverable className={ActShowMode ? null : styles.showMode} actions={actions} > {this.state.ReportIgnore ? null : this.state.postReported ? (

It seems that this post has been reported

The content may be inappropriate or compromising

{ this.setState({ ReportIgnore: true }) }} > Ignore
) : null}
} title={

ycore.router.go(`@${publisher.username}`) } className={styles.titleUser} > @{publisher.username} {ycore.booleanFix(publisher.verified) ? ( ) : null} {ycore.booleanFix(publisher.nsfw_flag) ? ( NSFW ) : null}{' '}

{ycore.booleanFix(is_post_pinned) ? ( ) : null}
} description={{post_time}} bordered="false" /> {postText ? (
{' '}

{' '}

) : null} {postFile ? (
{this.renderPostPlayer(postFile)}
) : null}
) } } export default PostCard