| ... | @@ -468,6 +468,18 @@ export function PullRequestSummaryTab({ | ... | @@ -468,6 +468,18 @@ export function PullRequestSummaryTab({ |
| 468 | const hiddenCommentCount = detail.comments.length - recentComments.length; | 468 | const hiddenCommentCount = detail.comments.length - recentComments.length; |
| 469 | const [commentOrder, setCommentOrder] = useState<"newest" | "oldest">("newest"); | 469 | const [commentOrder, setCommentOrder] = useState<"newest" | "oldest">("newest"); |
| 470 | const visibleComments = orderPullRequestComments(recentComments, commentOrder); | 470 | const visibleComments = orderPullRequestComments(recentComments, commentOrder); |
| | 471 | const showOldestCommentsButton = |
| | 472 | hiddenCommentCount > 0 ? ( |
| | 473 | <Button |
| | 474 | size="sm" |
| | 475 | variant="outline" |
| | 476 | className="w-full" |
| | 477 | onClick={() => setShown({ url: detail.url, count: shownComments + COMMENT_PAGE })} |
| | 478 | > |
| | 479 | Show {Math.min(hiddenCommentCount, COMMENT_PAGE)} oldest{" "} |
| | 480 | {hiddenCommentCount === 1 ? "comment" : "comments"} |
| | 481 | </Button> |
| | 482 | ) : null; |
| 471 | // Read from the whole conversation, not the window shown below it: a verdict older than the | 483 | // Read from the whole conversation, not the window shown below it: a verdict older than the |
| 472 | // last thirty comments still stands. | 484 | // last thirty comments still stands. |
| 473 | const reviewOutcomes = latestPullRequestReviewOutcomes(detail.comments, detail.commits); | 485 | const reviewOutcomes = latestPullRequestReviewOutcomes(detail.comments, detail.commits); |
| ... | @@ -864,22 +876,7 @@ export function PullRequestSummaryTab({ | ... | @@ -864,22 +876,7 @@ export function PullRequestSummaryTab({ |
| 864 | <p className="py-2 text-xs text-muted-foreground">No comments yet.</p> | 876 | <p className="py-2 text-xs text-muted-foreground">No comments yet.</p> |
| 865 | ) : ( | 877 | ) : ( |
| 866 | <div className="space-y-3"> | 878 | <div className="space-y-3"> |
| 867 | {hiddenCommentCount > 0 ? ( | 879 | {commentOrder === "oldest" ? showOldestCommentsButton : null} |
| 868 | // Hundreds of comments are hundreds of markdown renders, and the ones worth | | |
| 869 | // opening a pull request for are the recent ones. The rest are one press away and | | |
| 870 | // stay rendered once asked for. | | |
| 871 | <Button | | |
| 872 | size="sm" | | |
| 873 | variant="outline" | | |
| 874 | className="w-full" | | |
| 875 | onClick={() => | | |
| 876 | setShown({ url: detail.url, count: shownComments + COMMENT_PAGE }) | | |
| 877 | } | | |
| 878 | > | | |
| 879 | Show {Math.min(hiddenCommentCount, COMMENT_PAGE)} earlier{" "} | | |
| 880 | {hiddenCommentCount === 1 ? "comment" : "comments"} | | |
| 881 | </Button> | | |
| 882 | ) : null} | | |
| 883 | {visibleComments.map((comment) => { | 880 | {visibleComments.map((comment) => { |
| 884 | const thread = threadByCommentId.get(comment.id); | 881 | const thread = threadByCommentId.get(comment.id); |
| 885 | const body = visibleBody(comment.body); | 882 | const body = visibleBody(comment.body); |
| ... | @@ -991,6 +988,7 @@ export function PullRequestSummaryTab({ | ... | @@ -991,6 +988,7 @@ export function PullRequestSummaryTab({ |
| 991 | </article> | 988 | </article> |
| 992 | ); | 989 | ); |
| 993 | })} | 990 | })} |
| | 991 | {commentOrder === "newest" ? showOldestCommentsButton : null} |
| 994 | </div> | 992 | </div> |
| 995 | )} | 993 | )} |
| 996 | </> | 994 | </> |