-import {
- CommentView,
- GetSiteResponse,
- LemmyHttp,
- UserMentionView,
-} from 'lemmy-js-client';
+import { CommentView, GetSiteResponse } from "lemmy-js-client";
+import type { ParsedQs } from "qs";
+import { RequestState, WrappedLemmyHttp } from "./services/HttpService";
+import { ErrorPageData } from "./utils";
-export interface IsoData {
+/**
+ * This contains serialized data, it needs to be deserialized before use.
+ */
+export interface IsoData<T extends Record<string, RequestState<any>> = any> {
path: string;
- routeData: any[];
+ routeData: T;
site_res: GetSiteResponse;
- // Lang and theme
- lang: string;
- // communities?: ListCommunitiesResponse;
+ errorPageData?: ErrorPageData;
+}
+
+export type IsoDataOptionalSite<
+ T extends Record<string, RequestState<any>> = any
+> = Partial<IsoData<T>> &
+ Pick<IsoData<T>, Exclude<keyof IsoData<T>, "site_res">>;
+
+export interface ILemmyConfig {
+ wsHost?: string;
}
declare global {
interface Window {
isoData: IsoData;
+ lemmyConfig?: ILemmyConfig;
}
}
-export interface InitialFetchRequest {
- auth: string;
+export interface InitialFetchRequest<T extends ParsedQs = ParsedQs> {
+ auth?: string;
+ client: WrappedLemmyHttp;
path: string;
- client: LemmyHttp;
-}
-
-export interface CommentNode {
- comment_view: CommentView | UserMentionView;
- children?: CommentNode[];
- depth?: number;
+ query: T;
+ site: GetSiteResponse;
}
export interface PostFormParams {
- name: string;
+ name?: string;
url?: string;
body?: string;
- community_name?: string;
- community_id?: number;
-}
-
-export enum CommentSortType {
- Hot,
- Top,
- New,
- Old,
}
export enum CommentViewType {
Tree,
- Chat,
+ Flat,
}
export enum DataType {
Site,
}
-export enum UserDetailsView {
- Overview,
- Comments,
- Posts,
- Saved,
+export enum PersonDetailsView {
+ Overview = "Overview",
+ Comments = "Comments",
+ Posts = "Posts",
+ Saved = "Saved",
+}
+
+export enum PurgeType {
+ Person,
+ Community,
+ Post,
+ Comment,
+}
+
+export enum VoteType {
+ Upvote,
+ Downvote,
+}
+
+export interface CommentNodeI {
+ comment_view: CommentView;
+ children: Array<CommentNodeI>;
+ depth: number;
}