Fix edited at bug

This commit is contained in:
Noah 2022-08-28 20:56:26 -07:00
parent aa8d719fc4
commit 8a36ea6d24
3 changed files with 7 additions and 2 deletions

View File

@ -102,6 +102,11 @@ func (c *Comment) Delete() error {
return DB.Delete(c).Error return DB.Delete(c).Error
} }
// IsEdited returns if a comment was reasonably edited after it was created.
func (c *Comment) IsEdited() bool {
return c.UpdatedAt.Sub(c.CreatedAt) > 5*time.Second
}
type CommentCountMap map[uint64]int64 type CommentCountMap map[uint64]int64
// MapCommentCounts collects total numbers of comments over a set of table IDs. Returns a // MapCommentCounts collects total numbers of comments over a set of table IDs. Returns a

View File

@ -140,7 +140,7 @@
<div class="column content"> <div class="column content">
{{ToMarkdown .Message}} {{ToMarkdown .Message}}
{{if .UpdatedAt.After .CreatedAt}} {{if .IsEdited}}
<div class="mt-4"> <div class="mt-4">
<em title="{{.UpdatedAt.Format "2006-01-02 15:04:05"}}"> <em title="{{.UpdatedAt.Format "2006-01-02 15:04:05"}}">
<small>Edited {{SincePrettyCoarse .UpdatedAt}} ago</small> <small>Edited {{SincePrettyCoarse .UpdatedAt}} ago</small>

View File

@ -224,7 +224,7 @@
<div class="column content"> <div class="column content">
{{ToMarkdown .Message}} {{ToMarkdown .Message}}
{{if .UpdatedAt.After .CreatedAt}} {{if .IsEdited}}
<div class="mt-4"> <div class="mt-4">
<em title="{{.UpdatedAt.Format "2006-01-02 15:04:05"}}"> <em title="{{.UpdatedAt.Format "2006-01-02 15:04:05"}}">
<small>Edited {{SincePrettyCoarse .UpdatedAt}} ago</small> <small>Edited {{SincePrettyCoarse .UpdatedAt}} ago</small>