File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,11 @@ const getLatestFollowers = async () => {
2323
2424 try {
2525 while ( hasMore ) {
26- const { data } =
27- await octokit . rest . users . listFollowersForAuthenticatedUser ( {
28- username : username ,
29- per_page : perPage ,
30- page : page ,
31- } ) ;
26+ const { data } = await octokit . rest . users . listFollowersForAuthenticatedUser ( {
27+ username : username ,
28+ per_page : perPage ,
29+ page : page ,
30+ } ) ;
3231
3332 followers = followers . concat ( data ) ;
3433
@@ -42,18 +41,18 @@ const getLatestFollowers = async () => {
4241 const formattedFollowers = followers . map ( ( follower ) => ( {
4342 profileUrl : follower . html_url ,
4443 picUrl : follower . avatar_url ,
44+ followedAt : follower . created_at , // Fetch the follow date
4545 } ) ) ;
4646
4747 formattedFollowers . sort ( ( a , b ) => {
48- return a . profileUrl . localeCompare ( b . profileUrl ) ;
48+ return new Date ( b . followedAt ) - new Date ( a . followedAt ) ; // Sort by follow date
4949 } ) ;
5050
5151 return formattedFollowers ;
5252 } catch ( error ) {
5353 console . error ( "Error fetching followers:" , error . message ) ;
5454 }
5555} ;
56-
5756export async function handleFetchFollowers ( ) {
5857 const followers = await getLatestFollowers ( ) ;
5958 const followersLength = followers . length ;
You can’t perform that action at this time.
0 commit comments