mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
use class component for PostAdditions
This commit is contained in:
parent
b3bc39daef
commit
85477efb8d
@ -107,26 +107,15 @@ export function PostHeader(props) {
|
||||
</div>
|
||||
}
|
||||
|
||||
export const PostAdditions = React.memo((props) => {
|
||||
let { additions } = props
|
||||
|
||||
let carruselRef = React.useRef(null)
|
||||
|
||||
// fullfil url string additions
|
||||
additions = additions.map((addition) => {
|
||||
export class PostAdditions extends React.PureComponent {
|
||||
getAdditions = (data) => {
|
||||
return data.map((addition, index) => {
|
||||
if (typeof addition === "string") {
|
||||
addition = {
|
||||
url: addition,
|
||||
}
|
||||
}
|
||||
|
||||
return addition
|
||||
})
|
||||
|
||||
// then filter if has an valid url
|
||||
additions = additions.filter(addition => /^(http|https):\/\//.test(addition.url))
|
||||
|
||||
additions = additions.map((addition, index) => {
|
||||
const { url, id, name } = addition
|
||||
|
||||
const MediaRender = loadable(async () => {
|
||||
@ -189,19 +178,21 @@ export const PostAdditions = React.memo((props) => {
|
||||
</React.Suspense>
|
||||
</div>
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div className="additions">
|
||||
<antd.Carousel
|
||||
ref={carruselRef}
|
||||
arrows={true}
|
||||
nextArrow={<Icons.ChevronRight />}
|
||||
prevArrow={<Icons.ChevronLeft />}
|
||||
autoplay={props.autoCarrousel}
|
||||
autoplay={this.props.autoCarrousel}
|
||||
>
|
||||
{additions}
|
||||
{this.getAdditions(this.props.additions)}
|
||||
</antd.Carousel>
|
||||
</div>
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const PostContent = React.memo((props) => {
|
||||
let { message, additions } = props.data
|
||||
|
Loading…
x
Reference in New Issue
Block a user