]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/interfaces.ts
Use http client (#1081)
[lemmy-ui.git] / src / shared / interfaces.ts
index e09f3bd598c65ebff0208cc7ff03cbe6b41139e4..3b64f60533dc246b6fd6fe74f5dfb2387ef29fed 100644 (file)
@@ -1,16 +1,21 @@
-import {
-  CommentView,
-  GetSiteResponse,
-  LemmyHttp,
-  PersonMentionView,
-} 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";
 
+/**
+ * This contains serialized data, it needs to be deserialized before use.
+ */
 export interface IsoData {
   path: string;
-  routeData: any[];
+  routeData: RequestState<any>[];
   site_res: GetSiteResponse;
+  errorPageData?: ErrorPageData;
 }
 
+export type IsoDataOptionalSite = Partial<IsoData> &
+  Pick<IsoData, Exclude<keyof IsoData, "site_res">>;
+
 export interface ILemmyConfig {
   wsHost?: string;
 }
@@ -22,36 +27,23 @@ declare global {
   }
 }
 
-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 | PersonMentionView;
-  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 {
@@ -65,8 +57,26 @@ export enum BanType {
 }
 
 export enum PersonDetailsView {
-  Overview,
-  Comments,
-  Posts,
-  Saved,
+  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;
 }