@@ -27,7 +27,7 @@ struct CommentsView: View {
2727 // `dropFirst` because `first` is the actual post
2828 if listings!. dropFirst ( ) . map ( { $0. data. children } ) . flatMap ( { $0. map { $0. data } } ) . count > 0 {
2929 ForEach ( listings!. dropFirst ( ) . map ( { $0. data. children } ) . flatMap { $0. map { $0. data } } , id: \. id) { comment in
30- CommentView ( comment: comment, nestLevel: 0 )
30+ CommentView ( comment: comment, postAuthor : self . post . author , nestLevel: 0 )
3131 }
3232 } else {
3333 self . noComments
@@ -42,7 +42,16 @@ struct CommentsView: View {
4242
4343struct CommentView : View {
4444 let comment : Comment
45+ let postAuthor : String
4546 let nestLevel : Int
47+
48+ var authorText : some View {
49+ if comment. author == postAuthor {
50+ return Text ( comment. author) . foregroundColor ( . accentColor) . bold ( )
51+ } else {
52+ return Text ( comment. author)
53+ }
54+ }
4655
4756 var body : some View {
4857 Group {
@@ -56,12 +65,12 @@ struct CommentView: View {
5665 /// Content
5766 VStack ( alignment: . leading) {
5867 HStack {
59- Text ( comment . author )
68+ authorText
6069 Image ( systemName: " arrow.up " )
6170 Text ( " \( comment. score) " )
6271 }
63- . font ( . caption)
64- . opacity ( 0.75 )
72+ . font ( . caption)
73+ . opacity ( 0.75 )
6574 Text ( comment. body ?? " " )
6675 }
6776 }
@@ -70,7 +79,7 @@ struct CommentView: View {
7079 /// Recursive comments
7180 if comment. replies != nil {
7281 ForEach ( comment. replies!. data. children. map { $0. data } , id: \. id) { reply in
73- CommentView ( comment: reply, nestLevel: self . nestLevel + 1 )
82+ CommentView ( comment: reply, postAuthor : self . postAuthor , nestLevel: self . nestLevel + 1 )
7483 }
7584 }
7685 }
0 commit comments