Skip to content

Commit c5c272b

Browse files
committed
feat(FeedView): track more events, update styles
1 parent dbe143d commit c5c272b

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

src/store/events.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ import type { RepoEventsResponse } from "@/types/repo";
88

99
type RawEvent = RepoEventsResponse["data"][number];
1010

11-
const TARGET_EVENTS = ["WatchEvent", "ForkEvent"] as const;
11+
const TARGET_EVENTS = [
12+
"ForkEvent",
13+
"IssuesEvent",
14+
"MemberEvent",
15+
"PublicEvent",
16+
"WatchEvent"
17+
] as const;
1218

13-
function getActionString(action: RawEvent["type"]): string {
14-
switch (action) {
15-
case "WatchEvent": return "starred";
19+
function getActionString({ type, payload }: RawEvent): string {
20+
switch (type) {
1621
case "ForkEvent": return "forked";
17-
default: return action ?? "[unknown action]";
22+
case "IssuesEvent": return `${payload.action} issue #${payload.issue!.number} "${payload.issue!.title}" in`;
23+
case "MemberEvent": return "joined";
24+
case "PublicEvent": return "made public";
25+
case "WatchEvent": return "starred";
26+
default: return type ?? "[unknown action]";
1827
}
1928
}
2029

@@ -50,16 +59,15 @@ export const useEventsStore = createSharedComposable(() => {
5059
const { settings } = useSettingsStore();
5160
const isFeedAvailable = computed(() => !!settings.value.authToken && !!settings.value.username);
5261

53-
function formatEvents(acc: FeedEvent[], { id, type, repo, actor, created_at }: RawEvent): FeedEvent[] {
54-
const isTargetEvent = TARGET_EVENTS.some((targetType) => targetType === type);
55-
const isUserRelated = repo.name.startsWith(settings.value.username);
56-
if (isTargetEvent && isUserRelated) {
62+
function formatEvents(acc: FeedEvent[], event: RawEvent): FeedEvent[] {
63+
const isTargetEvent = TARGET_EVENTS.some((targetType) => targetType === event.type);
64+
if (isTargetEvent) {
5765
acc.push({
58-
id,
59-
date: dayjs(created_at).format("DD.MM.YY HH:mm"),
60-
username: actor.display_login ?? actor.login,
61-
action: getActionString(type),
62-
repo: repo.name
66+
id: event.id,
67+
date: dayjs(event.created_at).format("DD MMMM HH:mm"),
68+
username: event.actor.display_login ?? event.actor.login,
69+
action: getActionString(event),
70+
repo: event.repo.name
6371
});
6472
}
6573
return acc;

src/views/FeedView.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</span>
66
<ul v-else>
77
<li v-for="{ date, username, action, repo, id } in events" :key="id">
8-
{{ date }}:
8+
<time>{{ date }}</time>:
99
<a :href="`https://github.com/${username}`">{{ username }}</a>
1010
{{ action }}
1111
<a :href="`https://github.com/${repo}`">{{ repo }}</a>
@@ -24,9 +24,15 @@ const { events, amount } = useEventsStore();
2424
display: grid;
2525
gap: 0.5rem;
2626
padding-left: 1.25rem;
27-
list-style: disc;
28-
li a {
29-
font-weight: bold;
27+
list-style-type: circle;
28+
li {
29+
a {
30+
font-weight: bold;
31+
}
32+
time {
33+
font-size: 0.875rem;
34+
color: var(--accent);
35+
}
3036
}
3137
}
3238
}

0 commit comments

Comments
 (0)