]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/person/profile.tsx
Merge branch 'main' into breakout-role-utils
[lemmy-ui.git] / src / shared / components / person / profile.tsx
index c12114bc8f3d8e4fa2ccfb32dfdfb897b7dbad37..b6a3200d62bf833dd0316878711e160b2eceeee2 100644 (file)
@@ -90,6 +90,10 @@ import { CommunityLink } from "../community/community-link";
 import { PersonDetails } from "./person-details";
 import { PersonListing } from "./person-listing";
 
+type ProfileData = RouteDataResponse<{
+  personResponse: GetPersonDetailsResponse;
+}>;
+
 interface ProfileState {
   personRes: RequestState<GetPersonDetailsResponse>;
   personBlocked: boolean;
@@ -156,7 +160,7 @@ export class Profile extends Component<
   RouteComponentProps<{ username: string }>,
   ProfileState
 > {
-  private isoData = setIsoData(this.context);
+  private isoData = setIsoData<ProfileData>(this.context);
   state: ProfileState = {
     personRes: { state: "empty" },
     personBlocked: false,
@@ -208,7 +212,7 @@ export class Profile extends Component<
     if (FirstLoadService.isFirstLoad) {
       this.state = {
         ...this.state,
-        personRes: this.isoData.routeData[0],
+        personRes: this.isoData.routeData.personResponse,
         isIsomorphic: true,
       };
     }
@@ -267,14 +271,12 @@ export class Profile extends Component<
     }
   }
 
-  static fetchInitialData({
+  static async fetchInitialData({
     client,
     path,
     query: { page, sort, view: urlView },
     auth,
-  }: InitialFetchRequest<QueryParams<ProfileProps>>): Promise<
-    RequestState<any>
-  >[] {
+  }: InitialFetchRequest<QueryParams<ProfileProps>>): Promise<ProfileData> {
     const pathSplit = path.split("/");
 
     const username = pathSplit[2];
@@ -289,7 +291,9 @@ export class Profile extends Component<
       auth,
     };
 
-    return [client.getPersonDetails(form)];
+    return {
+      personResponse: await client.getPersonDetails(form),
+    };
   }
 
   get documentTitle(): string {