Skip to content

Commit d53dbef

Browse files
committed
A bit more on timeline rendering
1 parent a6fba11 commit d53dbef

2 files changed

Lines changed: 22 additions & 18 deletions

File tree

app/Sauron/UI/Issue.hs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ renderTimelineItem now totalItems idx (itemType, _extraBody) =
8383
hLimit maxCommentWidth $ borderFunc
8484
(topLabel username createdAt now)
8585
(markdownToWidgetsWithWidth (maxCommentWidth - 2) descriptionBody)
86-
Right item -> renderItemWithBorder now borderFunc item
86+
Right item -> renderItemWithBorder now (idx == totalItems - 1) borderFunc item
8787

8888
topLabel :: Text -> UTCTime -> UTCTime -> Widget n
8989
topLabel username createdAt now =
9090
(withAttr usernameAttr (str [i|#{username} |]) <+> str [i|opened #{timeFromNow (diffUTCTime now createdAt)}|])
9191
& padLeftRight 1
9292

93-
renderItemWithBorder :: UTCTime -> (Widget n -> Widget n -> Widget n) -> Either IssueEvent IssueComment -> Widget n
94-
renderItemWithBorder now borderFunc item =
93+
renderItemWithBorder :: UTCTime -> Bool -> (Widget n -> Widget n -> Widget n) -> Either IssueEvent IssueComment -> Widget n
94+
renderItemWithBorder now isLast borderFunc item =
9595
case item of
9696
Right comment -> renderComment now borderFunc comment
97-
Left event -> renderEvent now event
97+
Left event -> renderEvent now isLast event
9898

9999
renderComment :: UTCTime -> (Widget n -> Widget n -> Widget n) -> IssueComment -> Widget n
100100
renderComment now borderFunc (IssueComment {issueCommentUser=(SimpleUser {simpleUserLogin=(N username)}), issueCommentCreatedAt, ..}) =
@@ -103,23 +103,27 @@ renderComment now borderFunc (IssueComment {issueCommentUser=(SimpleUser {simple
103103
(markdownToWidgetsWithWidth (maxCommentWidth - 2) issueCommentBody)
104104
where commentTime = issueCommentCreatedAt
105105

106-
renderEvent :: UTCTime -> IssueEvent -> Widget n
107-
renderEvent now issueEvent =
106+
renderEvent :: UTCTime -> Bool -> IssueEvent -> Widget n
107+
renderEvent now isLast issueEvent =
108108
let actorName :: Text = case simpleUserLogin (issueEventActor issueEvent) of
109109
N username -> username
110110
eventText = getEventDescription (issueEventType issueEvent)
111111
iconWidget = getEventIconWithColor (issueEventType issueEvent)
112112
timeAgo = timeFromNow (diffUTCTime now (issueEventCreatedAt issueEvent))
113-
in hLimit maxCommentWidth $
114-
padLeft (Pad 4) $ hBox [
115-
iconWidget
116-
, str " "
117-
, withAttr usernameAttr $ str (toString actorName)
118-
, str " "
119-
, str eventText
120-
, str " "
121-
, withAttr italicText $ str timeAgo
122-
]
113+
eventLine = hLimit maxCommentWidth $
114+
padLeft (Pad 4) $ hBox [
115+
iconWidget
116+
, str " "
117+
, withAttr usernameAttr $ str (toString actorName)
118+
, str " "
119+
, str eventText
120+
, str " "
121+
, withAttr italicText $ str timeAgo
122+
]
123+
continuationLine = if isLast
124+
then emptyWidget
125+
else hLimit maxCommentWidth $ padLeft (Pad 4) $ withAttr timelineBorderAttr $ str ""
126+
in vBox [eventLine, continuationLine]
123127

124128
commentTopLabel :: Text -> UTCTime -> UTCTime -> Widget n
125129
commentTopLabel username commentTime now =

app/Sauron/UI/TimelineBorder.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ lastTimelineBorder label content =
9191

9292
let topBorder = hBox [
9393
withAttr timelineBorderAttr $ str "┌───"
94-
, withAttr timelineBorderAttr $ str ""
94+
, withAttr timelineBorderAttr $ str ""
9595
, withAttr timelineBorderAttr $ str ""
9696
, label
9797
, withAttr timelineBorderAttr $ str ""
@@ -100,7 +100,7 @@ lastTimelineBorder label content =
100100
]
101101
bottomBorder = hBox [
102102
withAttr timelineBorderAttr $ str "└───"
103-
, withAttr timelineBorderAttr $ str ""
103+
, withAttr timelineBorderAttr $ str ""
104104
, timelineHBorder
105105
, withAttr timelineBorderAttr $ str ""
106106
]

0 commit comments

Comments
 (0)