forked from thislooksfun/snoots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a method to get the approved contributors in a subreddit
Closes thislooksfun#49.
- Loading branch information
1 parent
a79b3d7
commit c1edba2
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { | ||
Fetcher, | ||
ListingContext, | ||
RedditListing, | ||
} from "../listing/listing"; | ||
import type { User } from "./object/base-object"; | ||
|
||
import { Listing, Pager } from "../listing/listing"; | ||
|
||
class UserPager extends Pager<User> { | ||
async fetch(context: ListingContext): Promise<UserListing> { | ||
const pg = await this.nextPage(context); | ||
return new UserListing(pg, context); | ||
} | ||
} | ||
|
||
/** @internal */ | ||
export class UserListing extends Listing<User> { | ||
constructor(l: RedditListing, context: ListingContext) { | ||
let fetcher: Fetcher<User> | undefined; | ||
|
||
if (l.after) { | ||
fetcher = new UserPager(l.after); | ||
} | ||
|
||
const users: User[] = []; | ||
for (const c of l.children) { | ||
users.push(context.client.users.fromRaw(c)); | ||
} | ||
|
||
super(context, users, fetcher); | ||
} | ||
} |