Skip to content

Commit

Permalink
feat: document link flair templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ekrzeptowski committed Mar 9, 2024
1 parent f0c6b48 commit 29257d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/reddit/subreddit/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import type {
} from "../types";
import type { BannedUser } from "../user/moderator-actioned/banned";
import type { ModeratorActionedUser } from "../user/moderator-actioned/base";
import type { SubredditData, SubredditFlair } from "./object";
import type { SubredditData } from "./object";
import type { SubredditFlair } from "./types";

import { BaseControls } from "../base-controls";
import { CommentListing } from "../comment/listing/listing";
Expand Down
25 changes: 8 additions & 17 deletions src/reddit/subreddit/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
SubredditControls,
TextPostOptions,
} from "./controls";
import type { SubredditType } from "./types";
import type { SubredditFlair, SubredditType } from "./types";

import { Content } from "../content";

Expand Down Expand Up @@ -182,7 +182,10 @@ export interface SubredditData extends ContentData {
// TODO: Document or remove SubredditData.lang
// lang: string;

/** Whether or not link flairs are enabled in this subreddit. */
linkFlairEnabled: boolean;

/** The position of the link flairs in this subreddit. */
linkFlairPosition: "" | "left" | "right";

// TODO: Document or remove SubredditData.mobileBannerImage
Expand Down Expand Up @@ -344,22 +347,6 @@ export interface SubredditData extends ContentData {
// wls: number;
}

export interface SubredditFlair {
text: string;
cssClass: string;
id: string;
textEditable: boolean;
type: "text" | "richtext";
allowableContent: string;
textColor: "dark" | "light";
modOnly: boolean;
richtext?: {
e: "text";
t: string;
}[];
backgroundColor: string;
}

/** A single subreddit. */
export class Subreddit extends Content implements SubredditData {
accountsActiveIsFuzzed: boolean;
Expand Down Expand Up @@ -631,6 +618,10 @@ export class Subreddit extends Content implements SubredditData {
return this.controls.getControversialPosts(this.displayName, time);
}

/**
* Get link flair templates for this subreddit.
* @returns A promise that resolves to an array of link flair templates.
*/
getLinkFlairTemplates(): Promise<SubredditFlair[]> {
return this.controls.getLinkFlairTemplates(this.displayName);
}
Expand Down
24 changes: 24 additions & 0 deletions src/reddit/subreddit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,27 @@ export type SubredditType =
| "private"
| "user"
| "public";

export type FileDetails = {
websocketUrl: string;
outboundUrl: string | undefined;
caption: string | undefined;
fileUrl: string;
mediaId: string;
};

export interface SubredditFlair {
text: string;
cssClass: string;
id: string;
textEditable: boolean;
type: "text" | "richtext";
allowableContent: string;
textColor: "dark" | "light";
modOnly: boolean;
richtext?: {
e: "text";
t: string;
}[];
backgroundColor: string;
}

0 comments on commit 29257d1

Please sign in to comment.