Sort local ID as a last resort as not all markdowns will have an SQL ID

This commit is contained in:
Christian Rocha 2020-12-15 11:22:52 -05:00
parent ca0dfecb1c
commit 84843e4f13

View file

@ -89,8 +89,10 @@ func (m markdownsByLocalFirst) Less(i, j int) bool {
return m[i].CreatedAt.After(m[j].CreatedAt)
}
// If the timestamps also match, sort by ID.
return m[i].ID > m[j].ID
// If the timestamps also match, sort by local ID.
localIDs := []ksuid.KSUID{m[i].localID, m[j].localID}
ksuid.Sort(localIDs)
return localIDs[0] == m[i].localID
}
func (m markdown) relativeTime() string {