Skip to content

Commit 87388a7

Browse files
committed
fix bug that sort comments incorrectly
1 parent 8cb94e6 commit 87388a7

4 files changed

Lines changed: 8 additions & 15 deletions

File tree

dist/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,12 @@ if (body) {
189189
repo,
190190
issue_number: pull_request_number,
191191
});
192+
193+
const compareDate = (a: Date, b: Date) => a == b ? 0 : a < b ? -1 : 1;
194+
192195
const sorted_comments = comments
193196
.filter((comment) => comment.user?.login == "cppwarningnotifier[bot]")
194-
.toSorted(
195-
(a, b) =>
196-
new Date(a.created_at).getSeconds() -
197-
new Date(b.created_at).getSeconds()
198-
);
197+
.toSorted((a, b) => compareDate(new Date(a.created_at), new Date(b.created_at)));
199198
if (sorted_comments.length > 0) {
200199
const latest_comment = sorted_comments[sorted_comments.length - 1];
201200
await octokit.graphql(`

0 commit comments

Comments
 (0)