mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-12 12:04: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>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PostAdditions = React.memo((props) => {
|
export class PostAdditions extends React.PureComponent {
|
||||||
let { additions } = props
|
getAdditions = (data) => {
|
||||||
|
return data.map((addition, index) => {
|
||||||
let carruselRef = React.useRef(null)
|
|
||||||
|
|
||||||
// fullfil url string additions
|
|
||||||
additions = additions.map((addition) => {
|
|
||||||
if (typeof addition === "string") {
|
if (typeof addition === "string") {
|
||||||
addition = {
|
addition = {
|
||||||
url: 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 { url, id, name } = addition
|
||||||
|
|
||||||
const MediaRender = loadable(async () => {
|
const MediaRender = loadable(async () => {
|
||||||
@ -189,19 +178,21 @@ export const PostAdditions = React.memo((props) => {
|
|||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</div>
|
</div>
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
return <div className="additions">
|
return <div className="additions">
|
||||||
<antd.Carousel
|
<antd.Carousel
|
||||||
ref={carruselRef}
|
|
||||||
arrows={true}
|
arrows={true}
|
||||||
nextArrow={<Icons.ChevronRight />}
|
nextArrow={<Icons.ChevronRight />}
|
||||||
prevArrow={<Icons.ChevronLeft />}
|
prevArrow={<Icons.ChevronLeft />}
|
||||||
autoplay={props.autoCarrousel}
|
autoplay={this.props.autoCarrousel}
|
||||||
>
|
>
|
||||||
{additions}
|
{this.getAdditions(this.props.additions)}
|
||||||
</antd.Carousel>
|
</antd.Carousel>
|
||||||
</div>
|
</div>
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const PostContent = React.memo((props) => {
|
export const PostContent = React.memo((props) => {
|
||||||
let { message, additions } = props.data
|
let { message, additions } = props.data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user