add edited info on message
This commit is contained in:
parent
5684e19582
commit
f01baf4c2e
|
|
@ -10,17 +10,25 @@ const Avatar = ({ user }: any) => {
|
||||||
const [firstLoad, setFirstLoad] = useState(true);
|
const [firstLoad, setFirstLoad] = useState(true);
|
||||||
|
|
||||||
if (firstLoad) {
|
if (firstLoad) {
|
||||||
fetch(gravatarUrl).then((response) => {
|
fetch(gravatarUrl)
|
||||||
if (response.status === 200) {
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
setAvatar(gravatarUrl);
|
setAvatar(gravatarUrl);
|
||||||
}
|
}
|
||||||
setFirstLoad(false);
|
setFirstLoad(false);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
setFirstLoad(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="avatar shrink-0">
|
<div className="avatar shrink-0">
|
||||||
<Image src={avatar} alt="avatar" className="rounded-full w-12 h-12 md:w-16 md:h-16 transition-all cursor-pointer" />
|
<Image
|
||||||
|
src={avatar}
|
||||||
|
alt="avatar"
|
||||||
|
className="rounded-full w-12 h-12 md:w-16 md:h-16 transition-all cursor-pointer"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ const Message = ({ message }: any) => {
|
||||||
</div>
|
</div>
|
||||||
<Text text={message.content} />
|
<Text text={message.content} />
|
||||||
{message.image && <Image src={message.image} alt="image" className="w-fit rounded-lg cursor-pointer" />}
|
{message.image && <Image src={message.image} alt="image" className="w-fit rounded-lg cursor-pointer" />}
|
||||||
|
<div className="flex justify-between">
|
||||||
<div className="text-grey-light date">
|
<div className="text-grey-light date">
|
||||||
{new Date(message.createdAt).toLocaleDateString(undefined, {
|
{new Date(message.createdAt).toLocaleDateString(undefined, {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
|
|
@ -49,6 +50,8 @@ const Message = ({ message }: any) => {
|
||||||
minute: 'numeric',
|
minute: 'numeric',
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
{message.edited && <div className="text-grey-light italic">Modifié</div>}
|
||||||
|
</div>
|
||||||
{me.data?.id === message.author.id ? null : (
|
{me.data?.id === message.author.id ? null : (
|
||||||
<Like
|
<Like
|
||||||
messageId={message.id}
|
messageId={message.id}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ model Post {
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
likes Int @default(0)
|
likes Int @default(0)
|
||||||
likedBy Like[]
|
likedBy Like[]
|
||||||
|
edited Boolean @default(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
model Like {
|
model Like {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ const editPost = async (post: Post): Promise<PrismaPost | null | Error> => {
|
||||||
data: {
|
data: {
|
||||||
content: post.content,
|
content: post.content,
|
||||||
image: post.image,
|
image: post.image,
|
||||||
|
edited: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ interface Post {
|
||||||
authorId: number;
|
authorId: number;
|
||||||
likes?: number | undefined;
|
likes?: number | undefined;
|
||||||
likedBy?: Like[] | undefined;
|
likedBy?: Like[] | undefined;
|
||||||
|
edited?: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Post: z.ZodType<Post> = z.object({
|
const Post: z.ZodType<Post> = z.object({
|
||||||
|
|
@ -17,6 +18,7 @@ const Post: z.ZodType<Post> = z.object({
|
||||||
authorId: z.number(),
|
authorId: z.number(),
|
||||||
likes: z.number().optional(),
|
likes: z.number().optional(),
|
||||||
likedBy: z.array(Like).optional(),
|
likedBy: z.array(Like).optional(),
|
||||||
|
edited: z.boolean().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export { Post };
|
export { Post };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue