MM-16949 Fix posts returned from unread API when the two different list contains parent post and comments (#11617)
* fix posts returned from unread API when the list contains parent post/s * add ExtendAll to PostList and update test per feedback * revert unintentional change to the other test and fix comment * update the existing postlist.Extend, filter unique values and update unit tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d4727ec649
Коммит
aef5ef4ed0
@@ -95,13 +95,29 @@ func (o *PostList) AddPost(post *Post) {
|
||||
o.Posts[post.Id] = post
|
||||
}
|
||||
|
||||
func (o *PostList) Extend(other *PostList) {
|
||||
for _, postId := range other.Order {
|
||||
if _, ok := o.Posts[postId]; !ok {
|
||||
o.AddPost(other.Posts[postId])
|
||||
o.AddOrder(postId)
|
||||
func (o *PostList) UniqueOrder() {
|
||||
keys := make(map[string]bool)
|
||||
order := []string{}
|
||||
for _, postId := range o.Order {
|
||||
if _, value := keys[postId]; !value {
|
||||
keys[postId] = true
|
||||
order = append(order, postId)
|
||||
}
|
||||
}
|
||||
|
||||
o.Order = order
|
||||
}
|
||||
|
||||
func (o *PostList) Extend(other *PostList) {
|
||||
for postId := range other.Posts {
|
||||
o.AddPost(other.Posts[postId])
|
||||
}
|
||||
|
||||
for _, postId := range other.Order {
|
||||
o.AddOrder(postId)
|
||||
}
|
||||
|
||||
o.UniqueOrder()
|
||||
}
|
||||
|
||||
func (o *PostList) SortByCreateAt() {
|
||||
|
||||
Ссылка в новой задаче
Block a user