import React from 'react'
import styles from './renders.less'
import * as antd from 'antd'
import * as ycore from 'ycore'
import * as Icons from '@ant-design/icons'
import Icon from '@ant-design/icons'
import {MediaPlayer, PostCard} from 'components'
const VerifiedBadge = () => ( )
export class __priPost extends React.Component{
renderContent(payload){
const { id, postText, postFile_full, post_time, publisher} = payload
if (!postFile_full) {
return(
)
}
return (
{postFile_full?
: null}
{postText?
: null}
)
}
render(){
const payload = this.props.payload
if (!payload) {
return (
This post not exists!!!
)
}
const { id, postText, postFile_full, post_time, publisher} = payload
return(
{publisher.username} {ycore.booleanFix(publisher.verified)? : null}
{post_time} {ycore.IsThisUser.dev()? `| #${id}` : null}
{this.renderContent(payload)}
)
}
}
export class __secComments extends React.Component {
state = {
comment_data: this.props.payload,
raw_comment: '',
loading: false
}
handleDeleteComment(id){
console.log(`Removing Comment with id => ${id}`)
ycore.Post_Comments.delete((err, res) => { if(err){return false} return this.reloadComments() }, {comment_id: id})
}
renderComment = (a) => {
const {id, time, Orginaltext, publisher} = a
const CommentMenu = (
this.handleDeleteComment(id)}> Delete
);
return (
@{publisher.username} {ycore.booleanFix(publisher.verified)? : null}
e.preventDefault()} className={styles.comment_user_ago}>{ycore.time.stmToAgo(time)}
)
}
HandleCommentInput = e => {
const { value } = e.target;
this.setState({ raw_comment: value })
};
reloadComments(){
try {
this.setState({ loading: true })
ycore.GetPostData(this.props.post_id, null, (err, res) =>{
const post_comments = JSON.parse(res)['post_comments']
this.setState({ comment_data: post_comments, loading: false})
})
} catch (error) {
return false
}
}
dispatchNewComment(){
const { raw_comment } = this.state
const { post_id } = this.props
if (raw_comment) {
ycore.ActionPost('comment', post_id, raw_comment, (err,res) =>{
if (err) {
ycore.notify.error('This action could not be performed.', err)
}
this.setState({ raw_comment: '' })
this.reloadComments()
return true
})
}
return false
}
render(){
const {comment_data, loading} = this.state
return(
Comments ({comment_data.length})
{loading?
:
(
this.renderComment(item)
)}
/>
}
this.dispatchNewComment()} placeholder="Write a comment..." allowClear onChange={this.HandleCommentInput} />
)
}
}