@@ -8,13 +8,22 @@ import type { RepoEventsResponse } from "@/types/repo";
88
99type 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 ;
0 commit comments