New comments display & Public attachment URLs
leojuriolli 12 months ago
New comment display
Because the comments can be infinitely nested as replies, their display on mobile could quickly break.
After a few changes, the same comment is 100% readable on mobile, even though it a deeply nested reply:
Before | After |
---|---|
Click here to go to this post.
Besides, I have also added the option to collapse comments, like on Reddit, by clicking on the left-side of the parent comment.
The next step is adding a reply/edit modal to the mobile comments component, to make replying/editing deeply nested comments a better experience.
Public attachment URLs
Before today, there was a flaw in the application's design. The attachment URLs were not public, even though they were publicly displayed, and not behind any authentication.
On a post's page, alongside the GET single post, all attachment URLs would be received via getSignedUrlPromise
:
await s3.getSignedUrlPromise("getObject", {
Bucket: BUCKET_NAME,
Key: `${postId}/${file.id}`,
ResponseContentDisposition: `attachment; filename ="${file.name}"`,
})
Even though there was no need for that, it was an extra call and waiting, instead of having the URL inside the post attachment object:
model Post {
...
title String
body String @db.Text
attachments Attachment[]
...
}
model Attachment {
id String @id @default(cuid())
name String @default("Uploaded file")
type String @default("unknown")
postId String
url String
}
Now an attachment can be fully accessed inside the post object, with its url
attribute pointing to the S3 bucket object, as now the bucket is also publicly accessible.