]> Untitled Git - lemmy-ui.git/commitdiff
Fix server-side rendering after first load.
authordudeami0 <dudeami0@gmail.com>
Fri, 23 Jun 2023 03:30:42 +0000 (23:30 -0400)
committerdudeami0 <dudeami0@gmail.com>
Fri, 23 Jun 2023 03:30:42 +0000 (23:30 -0400)
14 files changed:
src/shared/components/community/communities.tsx
src/shared/components/community/community.tsx
src/shared/components/home/admin-settings.tsx
src/shared/components/home/home.tsx
src/shared/components/home/instances.tsx
src/shared/components/modlog.tsx
src/shared/components/person/inbox.tsx
src/shared/components/person/profile.tsx
src/shared/components/person/registration-applications.tsx
src/shared/components/person/reports.tsx
src/shared/components/post/create-post.tsx
src/shared/components/post/post.tsx
src/shared/components/private_message/create-private-message.tsx
src/shared/components/search.tsx

index a84ec055568a9394a768b265f2adc1f386bdc288..35e89c360ff9f28569430d5f46dff35c893c26ff 100644 (file)
@@ -5,6 +5,7 @@ import {
   setIsoData,
   showLocal,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import {
   getPageFromString,
   getQueryParams,
@@ -67,7 +68,7 @@ export class Communities extends Component<any, CommunitiesState> {
     this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { listCommunitiesResponse } = this.isoData.routeData;
 
       this.state = {
index 111b47cd9d4747be7da88e94fa729413096456ec..3e7615a97b7fd8582d4f1000ff55fc00a67316cc 100644 (file)
@@ -15,6 +15,7 @@ import {
   updateCommunityBlock,
   updatePersonBlock,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import {
   getPageFromString,
   getQueryParams,
@@ -197,7 +198,7 @@ export class Community extends Component<
     this.handleFeaturePost = this.handleFeaturePost.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { communityRes, commentsRes, postsRes } = this.isoData.routeData;
 
       this.state = {
index 7ac69fedec5227662f03c0683116cafe47c1e864..6ab5b65915b679257f0d36c7f734ae3c9f6754da 100644 (file)
@@ -4,6 +4,7 @@ import {
   setIsoData,
   showLocal,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { capitalizeFirstLetter } from "@utils/helpers";
 import { RouteDataResponse } from "@utils/types";
 import classNames from "classnames";
@@ -74,7 +75,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
     this.handleCreateEmoji = this.handleCreateEmoji.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { bannedRes, instancesRes } = this.isoData.routeData;
 
       this.state = {
index bad771fccf15cfc0e16105113e2373c4afcfe145..da1be70bbcd193ec15596f8a9e487267e53cf922 100644 (file)
@@ -13,6 +13,7 @@ import {
   showLocal,
   updatePersonBlock,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import {
   getPageFromString,
   getQueryParams,
@@ -263,7 +264,7 @@ export class Home extends Component<any, HomeState> {
     this.handleFeaturePost = this.handleFeaturePost.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { trendingCommunitiesRes, commentsRes, postsRes } =
         this.isoData.routeData;
 
index b54c96af332dd045f7ab142e46c881a82e6123c9..9c38cf41f75e88454ed82d9602e2eb4d0a80cc50 100644 (file)
@@ -1,4 +1,5 @@
 import { setIsoData } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { RouteDataResponse } from "@utils/types";
 import { Component } from "inferno";
 import {
@@ -35,7 +36,7 @@ export class Instances extends Component<any, InstancesState> {
     super(props, context);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       this.state = {
         ...this.state,
         instancesRes: this.isoData.routeData.federatedInstancesResponse,
index 722f6e7088211749f6ee2a4a80b61ea88488c4db..e8c707ed69deede81d54d8e928462e119637e739 100644 (file)
@@ -5,6 +5,7 @@ import {
   personToChoice,
   setIsoData,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import {
   debounce,
   getIdFromString,
@@ -660,7 +661,7 @@ export class Modlog extends Component<
     this.handleModChange = this.handleModChange.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { res, communityRes, modUserResponse, userResponse } =
         this.isoData.routeData;
 
index 395875be4c49b975a3c3364ee99ee7c120115d95..3c9137017792650c9669154e2e50692ef323087a 100644 (file)
@@ -11,6 +11,7 @@ import {
   setIsoData,
   updatePersonBlock,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { RouteDataResponse } from "@utils/types";
 import { Component, linkEvent } from "inferno";
 import {
@@ -163,7 +164,7 @@ export class Inbox extends Component<any, InboxState> {
     this.handleEditMessage = this.handleEditMessage.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { mentionsRes, messagesRes, repliesRes } = this.isoData.routeData;
 
       this.state = {
index d00036871a04c9ec922c93a56e5c9b6eb43fec8b..6e0530d9902d489b8aadfb26b63773714a2c0f1d 100644 (file)
@@ -10,7 +10,11 @@ import {
   setIsoData,
   updatePersonBlock,
 } from "@utils/app";
-import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
+import {
+  isBrowser,
+  restoreScrollPosition,
+  saveScrollPosition,
+} from "@utils/browser";
 import {
   capitalizeFirstLetter,
   futureDaysToUnixTime,
@@ -206,7 +210,7 @@ export class Profile extends Component<
     this.handleFeaturePost = this.handleFeaturePost.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       this.state = {
         ...this.state,
         personRes: this.isoData.routeData.personResponse,
index d9eb6ad0a65ed1d9f858f90a688c377f47e51685..5e92c07339041bb4d2b4c5419e7c0a3b5c66c8e0 100644 (file)
@@ -3,6 +3,7 @@ import {
   myAuthRequired,
   setIsoData,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { RouteDataResponse } from "@utils/types";
 import { Component, linkEvent } from "inferno";
 import {
@@ -58,7 +59,7 @@ export class RegistrationApplications extends Component<
     this.handleApproveApplication = this.handleApproveApplication.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       this.state = {
         ...this.state,
         appsRes: this.isoData.routeData.listRegistrationApplicationsResponse,
index 8f5eaf366b6dcf0d99022ae2d8a13d455b85762e..9d04c8a7964e4d947b11ab905fff916ffa90fe8c 100644 (file)
@@ -5,6 +5,7 @@ import {
   myAuthRequired,
   setIsoData,
 } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { amAdmin } from "@utils/roles";
 import { RouteDataResponse } from "@utils/types";
 import { Component, linkEvent } from "inferno";
@@ -108,7 +109,7 @@ export class Reports extends Component<any, ReportsState> {
       this.handleResolvePrivateMessageReport.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { commentReportsRes, postReportsRes, messageReportsRes } =
         this.isoData.routeData;
 
index fe941830c6ab648ef9d05647568ef8081d2906ca..ed686f31f28f2002cc2505d139253caf339a9470 100644 (file)
@@ -1,4 +1,5 @@
 import { enableDownvotes, enableNsfw, myAuth, setIsoData } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { getIdFromString, getQueryParams } from "@utils/helpers";
 import type { QueryParams } from "@utils/types";
 import { Choice, RouteDataResponse } from "@utils/types";
@@ -69,7 +70,7 @@ export class CreatePost extends Component<
       this.handleSelectedCommunityChange.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { communityResponse: communityRes, initialCommunitiesRes } =
         this.isoData.routeData;
 
index f0aa3ff5bfc60b5a6bd40cdcff11cf0b551bc1da..54823f22a13e9e5070a35d365546f4c0d5f6bf75 100644 (file)
@@ -174,7 +174,7 @@ export class Post extends Component<any, PostState> {
     this.state = { ...this.state, commentSectionRef: createRef() };
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const { commentsRes, postRes } = this.isoData.routeData;
 
       this.state = {
index 8afd3488425edec8641bc9545b3fd5b0f11a6411..89ed75981ae62d75fecc0f435bf8e0737fe49a4e 100644 (file)
@@ -1,4 +1,5 @@
 import { getRecipientIdFromProps, myAuth, setIsoData } from "@utils/app";
+import { isBrowser } from "@utils/browser";
 import { RouteDataResponse } from "@utils/types";
 import { Component } from "inferno";
 import {
@@ -44,7 +45,7 @@ export class CreatePrivateMessage extends Component<
       this.handlePrivateMessageCreate.bind(this);
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       this.state = {
         ...this.state,
         recipientRes: this.isoData.routeData.recipientDetailsResponse,
index 473b18c483c430177a5a011dd825ece643f19387..3d04c500240b9abdc44491af5cd063a930688826 100644 (file)
@@ -11,7 +11,11 @@ import {
   setIsoData,
   showLocal,
 } from "@utils/app";
-import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
+import {
+  isBrowser,
+  restoreScrollPosition,
+  saveScrollPosition,
+} from "@utils/browser";
 import {
   capitalizeFirstLetter,
   debounce,
@@ -270,7 +274,7 @@ export class Search extends Component<any, SearchState> {
     };
 
     // Only fetch the data if coming from another route
-    if (FirstLoadService.isFirstLoad) {
+    if (!isBrowser() || FirstLoadService.isFirstLoad) {
       const {
         communityResponse: communityRes,
         creatorDetailsResponse: creatorDetailsRes,