mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
remove old logic
This commit is contained in:
parent
63b0784a5a
commit
9e86449f2b
@ -9,53 +9,10 @@ import "./index.less"
|
|||||||
|
|
||||||
export default class ExplorePosts extends React.Component {
|
export default class ExplorePosts extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
loading: true,
|
|
||||||
initialLoading: true,
|
|
||||||
hasMorePosts: true,
|
|
||||||
posts: [],
|
|
||||||
focusedSearcher: false,
|
focusedSearcher: false,
|
||||||
filledSearcher: false,
|
filledSearcher: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPosts = async ({
|
|
||||||
trim,
|
|
||||||
replace = false
|
|
||||||
} = {}) => {
|
|
||||||
await this.setState({
|
|
||||||
loading: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
// get posts from api
|
|
||||||
const result = await Post.getExplorePosts({
|
|
||||||
trim: trim ?? this.state.posts.length,
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log("Loaded posts => \n", result)
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
if (result.length === 0) {
|
|
||||||
await this.setState({
|
|
||||||
hasMorePosts: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.setState({
|
|
||||||
posts: replace ? result : [...this.state.posts, ...result],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.setState({
|
|
||||||
loading: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (this.state.initialLoading) {
|
|
||||||
await this.setState({
|
|
||||||
initialLoading: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleFocusSearcher = (to) => {
|
toggleFocusSearcher = (to) => {
|
||||||
to = to ?? !this.state.focusedSearcher
|
to = to ?? !this.state.focusedSearcher
|
||||||
@ -73,10 +30,6 @@ export default class ExplorePosts extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = async () => {
|
|
||||||
await this.loadPosts()
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <div className="postsExplore">
|
return <div className="postsExplore">
|
||||||
<div className="postsExplore_header">
|
<div className="postsExplore_header">
|
||||||
@ -89,11 +42,13 @@ export default class ExplorePosts extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
this.state.focusedSearcher || this.state.filledSearcher ? null : this.state.initialLoading ? <Skeleton active /> : <PostsList
|
this.state.focusedSearcher || this.state.filledSearcher ? null : <PostsList
|
||||||
loading={this.state.loading}
|
onLoadMore={Post.getExplorePosts}
|
||||||
hasMorePosts={this.state.hasMorePosts}
|
loadFromModel={Post.getExplorePosts}
|
||||||
onLoadMore={this.loadPosts}
|
watchTimeline={[
|
||||||
list={this.state.posts}
|
"post.new",
|
||||||
|
"post.delete",
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user