(comment: CommentData)
| 100 | } |
| 101 | |
| 102 | export function commentToNote(comment: CommentData): Note { |
| 103 | if (!comment || !comment.body) { |
| 104 | throw new Error('Invalid comment structure'); |
| 105 | } |
| 106 | |
| 107 | const { content, resolved, author, authorId } = parseNoteBody(comment.body); |
| 108 | |
| 109 | if (!content) { |
| 110 | throw new Error('Empty note content'); |
| 111 | } |
| 112 | |
| 113 | return { |
| 114 | id: comment.id.toString(), |
| 115 | // Falls back to the account that posted, for a comment typed on the host |
| 116 | // and for any note with no recorded author. |
| 117 | author: author || comment.user?.login || 'Unknown', |
| 118 | authorId, |
| 119 | // Only when the posting account IS the note's author — a recorded author |
| 120 | // means someone posted on their behalf, and its avatar would mislabel the |
| 121 | // note. The pane shows initials instead. |
| 122 | avatarUrl: authorId ? undefined : comment.user?.avatar_url || undefined, |
| 123 | timestamp: comment.created_at, |
| 124 | content, |
| 125 | resolved, |
| 126 | entrySlug: '', |
| 127 | }; |
| 128 | } |
| 129 | |
| 130 | export function commentsToNotes( |
| 131 | comments: CommentData[], |
no test coverage detected