Dwayne Harris 5 years ago
parent
commit
eacf80b4b0
  1. 8
      src/actions/posts.ts
  2. 1
      src/components/composer.tsx
  3. 2
      src/components/pages/view-post.tsx
  4. 2
      src/components/pages/view-user.tsx
  5. 9
      src/components/post.tsx
  6. 3
      src/styles/app.scss

8
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<string> => {
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<string> =
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))

1
src/components/composer.tsx

@ -126,6 +126,7 @@ const Composer: FC<Props> = ({ parent, onPost }) => {
withRateLimit(async ({ name, content }) => {
try {
const postId = await dispatch(createPost({
installation: installation.id,
visible: content.visible,
text: content.text,
cover: content.cover,

2
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')

2
src/components/pages/view-user.tsx

@ -53,8 +53,6 @@ const ViewUser: FC = () => {
if (!user) return <Loading />
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

9
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<Props> = ({ 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 (

3
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;
}

Loading…
Cancel
Save