diff --git a/src/actions/posts.ts b/src/actions/posts.ts index f65817a..03f1a75 100644 --- a/src/actions/posts.ts +++ b/src/actions/posts.ts @@ -14,6 +14,7 @@ interface CreatePostResponse { } interface CreatePostOptions { + installation: string visible: boolean text?: string cover?: string @@ -24,7 +25,7 @@ interface CreatePostOptions { export const createPost = (options: CreatePostOptions): AppThunkAction => { return async dispatch => { - const { visible, text, cover, attachments, data, parent } = options + const { installation, visible, text, cover, attachments, data, parent } = options dispatch(startRequest(RequestKey.CreatePost)) try { @@ -32,6 +33,7 @@ export const createPost = (options: CreatePostOptions): AppThunkAction = path: `/api/post`, method: 'post', body: { + installation, visible, text, cover, @@ -153,9 +155,9 @@ export const fetchUserPosts = (id: string, continuation?: string): AppThunkActio dispatch(setEntities(posts.entities)) if (continuation) { - dispatch(listAppend(`posts:${id}`, posts.keys, response.continuation)) + dispatch(listAppend(`user:${id}:posts`, posts.keys, response.continuation)) } else { - dispatch(listSet(`posts:${id}`, posts.keys, response.continuation)) + dispatch(listSet(`user:${id}:posts`, posts.keys, response.continuation)) } dispatch(finishRequest(RequestKey.FetchUserPosts, true)) diff --git a/src/components/composer.tsx b/src/components/composer.tsx index 462c3ac..a119096 100644 --- a/src/components/composer.tsx +++ b/src/components/composer.tsx @@ -126,6 +126,7 @@ const Composer: FC = ({ parent, onPost }) => { withRateLimit(async ({ name, content }) => { try { const postId = await dispatch(createPost({ + installation: installation.id, visible: content.visible, text: content.text, cover: content.cover, diff --git a/src/components/pages/view-post.tsx b/src/components/pages/view-post.tsx index dc97381..5f86d8e 100644 --- a/src/components/pages/view-post.tsx +++ b/src/components/pages/view-post.tsx @@ -43,7 +43,7 @@ const ViewPost: FC = () => { useEffect(() => { if (checked) fetch() - }, [checked]) + }, [checked, id]) useEffect(() => { if (post) setTitle('Post') diff --git a/src/components/pages/view-user.tsx b/src/components/pages/view-user.tsx index dc97ec6..420261a 100644 --- a/src/components/pages/view-user.tsx +++ b/src/components/pages/view-user.tsx @@ -53,8 +53,6 @@ const ViewUser: FC = () => { if (!user) return - console.log('user', user) - const isSelf = self && self.id === user.id const isGroup = self && self.group && user.group && self.group.id === user.group.id const imageUrl = user.imageUrl ? urlForBlob(config, user.imageUrl) : undefined diff --git a/src/components/post.tsx b/src/components/post.tsx index 86020b8..2e4d8bc 100644 --- a/src/components/post.tsx +++ b/src/components/post.tsx @@ -4,10 +4,11 @@ import { Link } from 'react-router-dom' import moment from 'moment' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faClock, faReplyAll, faExclamationCircle } from '@fortawesome/free-solid-svg-icons' -import { setEntity } from 'src/actions/entities' +import { setEntities } from 'src/actions/entities' import { Post, EntityType } from 'src/types' import User from 'src/components/user' +import { normalize } from 'src/utils/normalization' interface Props { post: Post @@ -18,10 +19,12 @@ const PostComponent: FC = ({ post }) => { const showCover = !!post.cover && !post.revealed const handleShowPost = () => { - dispatch(setEntity(EntityType.Post, { + const posts = normalize([{ ...post, revealed: true, - })) + }], EntityType.Post) + + dispatch(setEntities(posts.entities)) } return ( diff --git a/src/styles/app.scss b/src/styles/app.scss index 97da32a..178b9bc 100644 --- a/src/styles/app.scss +++ b/src/styles/app.scss @@ -177,10 +177,11 @@ div.post p { } div.post > div.cover { + background: linear-gradient(135deg, $white-ter, $grey-light); cursor: pointer; font-size: 1.1rem; font-weight: bold; - height: 100px; + padding: 30px; text-align: center; }