Skip to content

Commit bdcc763

Browse files
committed
feat(events): handle PullRequestEvent
1 parent cc4bcf4 commit bdcc763

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/store/events.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const TARGET_EVENTS = [
1313
"IssuesEvent",
1414
"MemberEvent",
1515
"PublicEvent",
16+
"PullRequestEvent",
1617
"WatchEvent"
1718
] as const;
1819
const FILTERED_ACTIONS = [
@@ -26,6 +27,7 @@ function getActionString({ type, payload }: RawEvent): string {
2627
case "IssuesEvent": return `${payload.action} issue`;
2728
case "MemberEvent": return "joined";
2829
case "PublicEvent": return "made public";
30+
case "PullRequestEvent": return `${payload.action} pull request`;
2931
case "WatchEvent": return "starred";
3032
default: return type ?? "[unknown action]";
3133
}
@@ -40,6 +42,11 @@ function composeEventUrl(event: RawEvent): string | null {
4042
const { html_url, full_name } = event.payload.forkee as { html_url: string, full_name: string };
4143
return `<a href="${html_url}" rel="noopener noreferrer" title="Go to forked repository">${full_name}</a> from `;
4244
}
45+
if (event.type === "PullRequestEvent" && "pull_request" in event.payload) {
46+
const { number } = event.payload.pull_request as { number: number };
47+
const html_url = `https://github.com/${event.repo.name}/pull/${number}`;
48+
return `<a href="${html_url}" rel="noopener noreferrer" title="Go to pull request">#${number}</a> in `;
49+
}
4350
return null;
4451
}
4552

@@ -79,9 +86,10 @@ export const useEventsStore = createGlobalState(() => {
7986
function formatEvents(acc: FeedEvent[], event: RawEvent): FeedEvent[] {
8087
const isTargetEvent = TARGET_EVENTS.some((targetType) => targetType === event.type);
8188
if (isTargetEvent) {
82-
if (event.type === "IssuesEvent" && FILTERED_ACTIONS.some((action) => action === event.payload.action)) {
83-
return acc;
84-
}
89+
if (
90+
FILTERED_ACTIONS.some((action) => action === event.payload.action) ||
91+
event.actor.login.includes("dependabot")
92+
) { return acc; }
8593
const feedEvent: FeedEvent = {
8694
id: event.id,
8795
date: dayjs(event.created_at).format("DD MMMM HH:mm"),

0 commit comments

Comments
 (0)