lemmy-ui/src/shared/interfaces.ts
2024-04-18 09:25:42 -04:00

103 lines
1.9 KiB
TypeScript

import { ErrorPageData } from "@utils/types";
import {
CommentReply,
CommentView,
GetSiteResponse,
PersonMention,
} from "lemmy-js-client";
import { RequestState } from "./services/HttpService";
import { Match } from "inferno-router/dist/Route";
/**
* This contains serialized data, it needs to be deserialized before use.
*/
export interface IsoData<T extends RouteData = any> {
path: string;
routeData: T;
site_res: GetSiteResponse;
errorPageData?: ErrorPageData;
showAdultConsentModal: boolean;
}
export type IsoDataOptionalSite<T extends RouteData = any> = Partial<
IsoData<T>
> &
Pick<IsoData<T>, Exclude<keyof IsoData<T>, "site_res">>;
declare global {
interface Window {
isoData: IsoData;
checkLazyScripts?: () => void;
}
}
export interface InitialFetchRequest<
P extends Record<string, string> = Record<string, never>,
T extends Record<string, any> = Record<string, never>,
> {
path: string;
query: T;
match: Match<P>;
site: GetSiteResponse;
headers: { [key: string]: string };
}
export interface PostFormParams {
name?: string;
url?: string;
body?: string;
}
export enum CommentViewType {
Tree,
Flat,
}
export enum DataType {
Post,
Comment,
}
export enum BanType {
Community,
Site,
}
export enum PersonDetailsView {
Overview = "Overview",
Comments = "Comments",
Posts = "Posts",
Saved = "Saved",
Uploads = "Uploads",
}
export enum PurgeType {
Person,
Community,
Post,
Comment,
}
export enum VoteType {
Upvote,
Downvote,
}
export enum VoteContentType {
Post,
Comment,
}
export type CommentNodeView = Omit<CommentView, "banned_from_community"> &
Partial<Pick<CommentView, "banned_from_community">> & {
person_mention?: PersonMention;
comment_reply?: CommentReply;
};
export interface CommentNodeI {
comment_view: CommentNodeView;
children: Array<CommentNodeI>;
depth: number;
}
export type RouteData = Record<string, RequestState<any>>;