ChildChatRows converts child chat rows to codersdk.Chat values, resolving diff statuses from the shared map. When diffStatuses is non-nil, children without an entry receive an empty DiffStatus.
( children []database.GetChildChatsByParentIDsRow, diffStatuses map[uuid.UUID]database.ChatDiffStatus, )
| 1953 | // resolving diff statuses from the shared map. When diffStatuses |
| 1954 | // is non-nil, children without an entry receive an empty DiffStatus. |
| 1955 | func ChildChatRows( |
| 1956 | children []database.GetChildChatsByParentIDsRow, |
| 1957 | diffStatuses map[uuid.UUID]database.ChatDiffStatus, |
| 1958 | ) []codersdk.Chat { |
| 1959 | result := make([]codersdk.Chat, len(children)) |
| 1960 | for i, row := range children { |
| 1961 | diffStatus, ok := diffStatuses[row.Chat.ID] |
| 1962 | if ok { |
| 1963 | result[i] = Chat(row.Chat, &diffStatus, nil) |
| 1964 | } else { |
| 1965 | result[i] = Chat(row.Chat, nil, nil) |
| 1966 | if diffStatuses != nil { |
| 1967 | emptyDiffStatus := ChatDiffStatus(row.Chat.ID, nil) |
| 1968 | result[i].DiffStatus = &emptyDiffStatus |
| 1969 | } |
| 1970 | } |
| 1971 | result[i].HasUnread = row.HasUnread |
| 1972 | } |
| 1973 | return result |
| 1974 | } |
| 1975 | |
| 1976 | // ChatRowsWithChildren converts root chat rows and their child rows |
| 1977 | // into codersdk.Chat values with children embedded under each parent. |
no test coverage detected