fixMutableThread is a helper method to finalize a mutableThread struct (partially constructed comment thread) as a CommentThread struct (fully constructed comment thread).
(mutableThread *mutableThread)
| 195 | // (partially constructed comment thread) as a CommentThread struct |
| 196 | // (fully constructed comment thread). |
| 197 | func fixMutableThread(mutableThread *mutableThread) CommentThread { |
| 198 | var children []CommentThread |
| 199 | edited := len(mutableThread.Edits) > 0 |
| 200 | for _, mutableChild := range mutableThread.Children { |
| 201 | child := fixMutableThread(mutableChild) |
| 202 | if (!edited) && child.Edited { |
| 203 | edited = true |
| 204 | } |
| 205 | children = append(children, child) |
| 206 | } |
| 207 | comment := &mutableThread.Comment |
| 208 | if len(mutableThread.Edits) > 0 { |
| 209 | sort.Stable(commentsByTimestamp(mutableThread.Edits)) |
| 210 | comment = mutableThread.Edits[len(mutableThread.Edits)-1] |
| 211 | } |
| 212 | |
| 213 | return CommentThread{ |
| 214 | Hash: mutableThread.Hash, |
| 215 | Comment: *comment, |
| 216 | Original: &mutableThread.Comment, |
| 217 | Edits: mutableThread.Edits, |
| 218 | Children: children, |
| 219 | Edited: edited, |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // This function builds the comment thread tree from the log-based list of comments. |
| 224 | // |
no test coverage detected