1package board
2
3import (
4 "github.com/dustin/go-humanize"
5
6 "github.com/git-bug/git-bug/entities/identity"
7 "github.com/git-bug/git-bug/entity"
8
9 "github.com/git-bug/git-bug/util/timestamp"
10)
11
12var _ Item = &Draft{}
13
14type Draft struct {
15 // combinedId should be the result of entity.CombineIds with the Board id and the id
16 // of the Operation that created the Draft
17 combinedId entity.CombinedId
18
19 Author identity.Interface
20 Title string
21 Message string
22
23 // Creation time of the comment.
24 // Should be used only for human display, never for ordering as we can't rely on it in a distributed system.
25 unixTime timestamp.Timestamp
26}
27
28func (d *Draft) CombinedId() entity.CombinedId {
29 if d.combinedId == "" || d.combinedId == entity.UnsetCombinedId {
30 // simply panic as it would be a coding error (no id provided at construction)
31 panic("no combined id")
32 }
33 return d.combinedId
34}
35
36// FormatTimeRel format the UnixTime of the comment for human consumption
37func (d *Draft) FormatTimeRel() string {
38 return humanize.Time(d.unixTime.Time())
39}
40
41func (d *Draft) FormatTime() string {
42 return d.unixTime.Time().Format("Mon Jan 2 15:04:05 2006 +0200")
43}
44
45// IsAuthored is a sign post method for gqlgen
46func (d *Draft) IsAuthored() {}