Skip to content

Commit 8647c8c

Browse files
committed
Fixes the issue where comments do not reset the timer.
1 parent 91abaa2 commit 8647c8c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ async function getTimeInactiveInHours(issue) {
4040
const commentsAry = comments.data.sort((a, b) => {
4141
return toUnixTimestamp(b.created_at) - toUnixTimestamp(a.created_at);
4242
});
43-
commentsAry.forEach(comment => {
43+
for (var i = 0; i < commentsAry.length; i++) {
44+
const comment = commentsAry[i];
4445
if (comment.user.login === 'github-actions[bot]') {
45-
return true;
46+
continue;
4647
}
4748
else {
4849
lastUpdated = comment.created_at;
49-
return false;
50+
break;
5051
}
51-
});
52+
}
5253

5354
if (!lastUpdated) {
5455
// If we get here, it means there were no comments, or they were all from
@@ -66,14 +67,15 @@ async function getTimeInactiveInHours(issue) {
6667
const eventsAry = events.data.sort((a, b) => {
6768
return toUnixTimestamp(b.created_at) - toUnixTimestamp(a.created_at);
6869
});
69-
eventsAry.forEach(event => {
70+
for (var i = 0; i < eventsAry.length; i++) {
71+
const event = eventsAry[i];
7072
if (event.event === 'assigned') {
71-
if ((new Date(event.created_at).getTime()) > (new Date(lastUpdated).getTime())) {
73+
if (toUnixTimestamp(event.created_at) > toUnixTimestamp(lastUpdated)) {
7274
lastUpdated = event.created_at;
7375
}
74-
return false; // Found the latest event, no need to continue
76+
break; // Found the latest event, no need to continue
7577
}
76-
});
78+
}
7779

7880
// Convert lastUpdated to timeInactiveInHours
7981
var timeInactiveInHours = null;

0 commit comments

Comments
 (0)