diff --git a/client/src/components/posts/Post.tsx b/client/src/components/posts/Post.tsx index 7888cab..27ecdf7 100644 --- a/client/src/components/posts/Post.tsx +++ b/client/src/components/posts/Post.tsx @@ -14,7 +14,7 @@ import { useState } from 'react' import { EditorContent, useEditor } from '@tiptap/react' import StarterKit from '@tiptap/starter-kit' import Placeholder from '@tiptap/extension-placeholder' -import useUpdatePostMutation from '@/hooks/useUpdatePostMutation' +import { useUpdatePostMutation } from '@/hooks' import { Button } from '../ui/button' interface PostProps { @@ -98,6 +98,7 @@ interface UpdatePostFormProps extends PostProps { const UpdatePostForm = ({ post, setEditing }: UpdatePostFormProps) => { const { mutate: updatePost } = useUpdatePostMutation() const editor = useEditor({ + content: post.content, extensions: [ StarterKit.configure({ bold: false, @@ -107,8 +108,7 @@ const UpdatePostForm = ({ post, setEditing }: UpdatePostFormProps) => { placeholder: "What's on your mind?" }) ], - immediatelyRender: true, - content: post.content + immediatelyRender: true }) const content = editor?.getText({ blockSeparator: '\n' }) || '' const handleSubmit = () => { @@ -147,24 +147,41 @@ interface MediaPreviewProps { } const MediaPreview = ({ media }: MediaPreviewProps) => { + const handleMediaError = (e: React.SyntheticEvent) => { + e.currentTarget.classList.add('hidden') + const fallbackDiv = document.createElement('div') + fallbackDiv.className = 'flex items-center justify-center h-48 bg-muted rounded-md' + fallbackDiv.innerText = 'Media failed to load' + e.currentTarget.parentNode?.appendChild(fallbackDiv) + } + const mediaObject = { IMAGE: ( -
- + Post attachment
), VIDEO: ( -
-