diff --git a/packages/app/src/models/post/index.js b/packages/app/src/models/post/index.js
index d5e3174d..d74baae0 100755
--- a/packages/app/src/models/post/index.js
+++ b/packages/app/src/models/post/index.js
@@ -90,4 +90,23 @@ export default class Post {
return request
}
+
+ static async getUserPosts({ user_id, trim, limit }) {
+ if (!Post.bridge) {
+ throw new Error("Bridge is not available")
+ }
+
+ if (!user_id) {
+ // use current user_id
+ user_id = app.userData?._id
+ }
+
+ const request = Post.bridge.get.userPosts(undefined, {
+ user_id,
+ trim: trim ?? 0,
+ limit: limit ?? window.app.settings.get("feed_max_fetch"),
+ })
+
+ return request
+ }
}
\ No newline at end of file
diff --git a/packages/app/src/pages/account/tabs/posts.jsx b/packages/app/src/pages/account/tabs/posts.jsx
index 4e028e43..ccff3fac 100755
--- a/packages/app/src/pages/account/tabs/posts.jsx
+++ b/packages/app/src/pages/account/tabs/posts.jsx
@@ -1,11 +1,83 @@
import React from "react"
+import { Skeleton } from "antd"
+import { Icons } from "components/Icons"
-import { PostsFeed } from "components"
+import { PostsList } from "components"
+import Post from "models/post"
-export default React.memo((props) => {
- return
-
+const emptyListRender = () => {
+ return
+
+ This user has no posts yet.
+
-})
\ No newline at end of file
+}
+
+export default class UserPosts extends React.Component {
+ state = {
+ loading: true,
+ initialLoading: true,
+ hasMorePosts: true,
+ posts: [],
+ }
+
+ loadData = async ({
+ trim,
+ replace = false
+ } = {}) => {
+ await this.setState({
+ loading: true,
+ })
+
+ const result = await Post.getUserPosts({
+ user_id: this.props.state.user._id,
+ trim: trim ?? this.state.posts.length,
+ })
+
+ console.log("Loaded data => \n", result)
+
+ if (result) {
+ if (result.length === 0) {
+ await this.setState({
+ hasMorePosts: false,
+ loading: false,
+ initialLoading: 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,
+ })
+ }
+ }
+
+ componentDidMount() {
+ this.loadData()
+ }
+
+ render() {
+ return
+ {
+ this.state.initialLoading ?
:
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/packages/server/src/controllers/PostsController/index.js b/packages/server/src/controllers/PostsController/index.js
index 6eca7959..84a86415 100755
--- a/packages/server/src/controllers/PostsController/index.js
+++ b/packages/server/src/controllers/PostsController/index.js
@@ -38,6 +38,22 @@ export default class PostsController extends Controller {
return res.json(posts)
})
},
+ "/user_posts": {
+ middlewares: ["withOptionalAuthentication"],
+ fn: Schematized({
+ required: ["user_id"],
+ select: ["user_id"]
+ }, async (req, res) => {
+ let posts = await GetPostData({
+ limit: req.query?.limit,
+ skip: req.query?.trim,
+ for_user_id: req.user?._id.toString(),
+ from_user_id: req.query?.user_id,
+ })
+
+ return res.json(posts)
+ })
+ },
"/post": {
middlewares: ["withOptionalAuthentication"],
fn: Schematized({