This commit is contained in:
		
						commit
						cccc5921ad
					
				|  | @ -8,6 +8,10 @@ export type Post = { | |||
|   creatorId: string // User id
 | ||||
|   createdTime: number | ||||
|   slug: string | ||||
| 
 | ||||
|   // denormalized user fields
 | ||||
|   creatorName: string | ||||
|   creatorUsername: string | ||||
| } | ||||
| 
 | ||||
| export type DateDoc = Post & { | ||||
|  |  | |||
|  | @ -100,6 +100,8 @@ export const createpost = newEndpoint({}, async (req, auth) => { | |||
|     createdTime: Date.now(), | ||||
|     content: content, | ||||
|     contractSlug, | ||||
|     creatorName: creator.name, | ||||
|     creatorUsername: creator.username, | ||||
|   }) | ||||
| 
 | ||||
|   await postRef.create(post) | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ import { DocumentIcon } from '@heroicons/react/solid' | |||
| import clsx from 'clsx' | ||||
| import { Post } from 'common/post' | ||||
| import Link from 'next/link' | ||||
| import { useUserById } from 'web/hooks/use-user' | ||||
| import { postPath } from 'web/lib/firebase/posts' | ||||
| import { fromNow } from 'web/lib/util/time' | ||||
| import { Avatar } from './avatar' | ||||
|  | @ -17,13 +16,8 @@ export function PostCard(props: { | |||
|   highlightOptions?: CardHighlightOptions | ||||
| }) { | ||||
|   const { post, onPostClick, highlightOptions } = props | ||||
|   const creatorId = post.creatorId | ||||
| 
 | ||||
|   const user = useUserById(creatorId) | ||||
|   const { itemIds: itemIds, highlightClassName } = highlightOptions || {} | ||||
| 
 | ||||
|   if (!user) return <> </> | ||||
| 
 | ||||
|   return ( | ||||
|     <div className="relative py-1"> | ||||
|       <Card | ||||
|  | @ -33,14 +27,14 @@ export function PostCard(props: { | |||
|         )} | ||||
|       > | ||||
|         <div className="flex-shrink-0"> | ||||
|           <Avatar className="h-12 w-12" username={user?.username} /> | ||||
|           <Avatar className="h-12 w-12" username={post.creatorUsername} /> | ||||
|         </div> | ||||
|         <div className=""> | ||||
|           <div className="text-sm text-gray-500"> | ||||
|             <UserLink | ||||
|               className="text-neutral" | ||||
|               name={user?.name} | ||||
|               username={user?.username} | ||||
|               name={post.creatorName} | ||||
|               username={post.creatorUsername} | ||||
|             /> | ||||
|             <span className="mx-1">•</span> | ||||
|             <span className="text-gray-500">{fromNow(post.createdTime)}</span> | ||||
|  |  | |||
|  | @ -52,7 +52,13 @@ export default function CreateDateDocPage() { | |||
| 
 | ||||
|     const newPost: Omit< | ||||
|       DateDoc, | ||||
|       'id' | 'creatorId' | 'createdTime' | 'slug' | 'contractSlug' | ||||
|       | 'id' | ||||
|       | 'creatorId' | ||||
|       | 'createdTime' | ||||
|       | 'slug' | ||||
|       | 'contractSlug' | ||||
|       | 'creatorUsername' | ||||
|       | 'creatorName' | ||||
|     > & { question?: string } = removeUndefinedProps({ | ||||
|       title, | ||||
|       subtitle, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user