From: dudeami0 Date: Fri, 23 Jun 2023 05:04:03 +0000 (-0400) Subject: Moved `!isBrowser()` check to `FirstLoadServer.isFirstLoad` X-Git-Url: http://these/git/%7B%60https:/static/%22https:/hacktivis.me/%22?a=commitdiff_plain;h=d706b6ba27866ad8b57d9b48743f04e63ba2dcbe;p=lemmy-ui.git Moved `!isBrowser()` check to `FirstLoadServer.isFirstLoad` --- diff --git a/src/shared/components/community/communities.tsx b/src/shared/components/community/communities.tsx index 35e89c3..a84ec05 100644 --- a/src/shared/components/community/communities.tsx +++ b/src/shared/components/community/communities.tsx @@ -5,7 +5,6 @@ import { setIsoData, showLocal, } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { getPageFromString, getQueryParams, @@ -68,7 +67,7 @@ export class Communities extends Component { this.handleListingTypeChange = this.handleListingTypeChange.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { listCommunitiesResponse } = this.isoData.routeData; this.state = { diff --git a/src/shared/components/community/community.tsx b/src/shared/components/community/community.tsx index 3e7615a..111b47c 100644 --- a/src/shared/components/community/community.tsx +++ b/src/shared/components/community/community.tsx @@ -15,7 +15,6 @@ import { updateCommunityBlock, updatePersonBlock, } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { getPageFromString, getQueryParams, @@ -198,7 +197,7 @@ export class Community extends Component< this.handleFeaturePost = this.handleFeaturePost.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { communityRes, commentsRes, postsRes } = this.isoData.routeData; this.state = { diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index 6ab5b65..7ac69fe 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -4,7 +4,6 @@ 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"; @@ -75,7 +74,7 @@ export class AdminSettings extends Component { this.handleCreateEmoji = this.handleCreateEmoji.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { bannedRes, instancesRes } = this.isoData.routeData; this.state = { diff --git a/src/shared/components/home/home.tsx b/src/shared/components/home/home.tsx index da1be70..bad771f 100644 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@ -13,7 +13,6 @@ import { showLocal, updatePersonBlock, } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { getPageFromString, getQueryParams, @@ -264,7 +263,7 @@ export class Home extends Component { this.handleFeaturePost = this.handleFeaturePost.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { trendingCommunitiesRes, commentsRes, postsRes } = this.isoData.routeData; diff --git a/src/shared/components/home/instances.tsx b/src/shared/components/home/instances.tsx index 9c38cf4..b54c96a 100644 --- a/src/shared/components/home/instances.tsx +++ b/src/shared/components/home/instances.tsx @@ -1,5 +1,4 @@ import { setIsoData } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { RouteDataResponse } from "@utils/types"; import { Component } from "inferno"; import { @@ -36,7 +35,7 @@ export class Instances extends Component { super(props, context); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { this.state = { ...this.state, instancesRes: this.isoData.routeData.federatedInstancesResponse, diff --git a/src/shared/components/modlog.tsx b/src/shared/components/modlog.tsx index e8c707e..722f6e7 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -5,7 +5,6 @@ import { personToChoice, setIsoData, } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { debounce, getIdFromString, @@ -661,7 +660,7 @@ export class Modlog extends Component< this.handleModChange = this.handleModChange.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { res, communityRes, modUserResponse, userResponse } = this.isoData.routeData; diff --git a/src/shared/components/person/inbox.tsx b/src/shared/components/person/inbox.tsx index 3c91370..395875b 100644 --- a/src/shared/components/person/inbox.tsx +++ b/src/shared/components/person/inbox.tsx @@ -11,7 +11,6 @@ import { setIsoData, updatePersonBlock, } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { @@ -164,7 +163,7 @@ export class Inbox extends Component { this.handleEditMessage = this.handleEditMessage.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { mentionsRes, messagesRes, repliesRes } = this.isoData.routeData; this.state = { diff --git a/src/shared/components/person/profile.tsx b/src/shared/components/person/profile.tsx index 6e0530d..d000368 100644 --- a/src/shared/components/person/profile.tsx +++ b/src/shared/components/person/profile.tsx @@ -10,11 +10,7 @@ import { setIsoData, updatePersonBlock, } from "@utils/app"; -import { - isBrowser, - restoreScrollPosition, - saveScrollPosition, -} from "@utils/browser"; +import { restoreScrollPosition, saveScrollPosition } from "@utils/browser"; import { capitalizeFirstLetter, futureDaysToUnixTime, @@ -210,7 +206,7 @@ export class Profile extends Component< this.handleFeaturePost = this.handleFeaturePost.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { this.state = { ...this.state, personRes: this.isoData.routeData.personResponse, diff --git a/src/shared/components/person/registration-applications.tsx b/src/shared/components/person/registration-applications.tsx index 5e92c07..d9eb6ad 100644 --- a/src/shared/components/person/registration-applications.tsx +++ b/src/shared/components/person/registration-applications.tsx @@ -3,7 +3,6 @@ import { myAuthRequired, setIsoData, } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { RouteDataResponse } from "@utils/types"; import { Component, linkEvent } from "inferno"; import { @@ -59,7 +58,7 @@ export class RegistrationApplications extends Component< this.handleApproveApplication = this.handleApproveApplication.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { this.state = { ...this.state, appsRes: this.isoData.routeData.listRegistrationApplicationsResponse, diff --git a/src/shared/components/person/reports.tsx b/src/shared/components/person/reports.tsx index 9d04c8a..8f5eaf3 100644 --- a/src/shared/components/person/reports.tsx +++ b/src/shared/components/person/reports.tsx @@ -5,7 +5,6 @@ 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"; @@ -109,7 +108,7 @@ export class Reports extends Component { this.handleResolvePrivateMessageReport.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { commentReportsRes, postReportsRes, messageReportsRes } = this.isoData.routeData; diff --git a/src/shared/components/post/create-post.tsx b/src/shared/components/post/create-post.tsx index ed686f3..fe94183 100644 --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@ -1,5 +1,4 @@ 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"; @@ -70,7 +69,7 @@ export class CreatePost extends Component< this.handleSelectedCommunityChange.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { communityResponse: communityRes, initialCommunitiesRes } = this.isoData.routeData; diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 54823f2..f0aa3ff 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -174,7 +174,7 @@ export class Post extends Component { this.state = { ...this.state, commentSectionRef: createRef() }; // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { commentsRes, postRes } = this.isoData.routeData; this.state = { diff --git a/src/shared/components/private_message/create-private-message.tsx b/src/shared/components/private_message/create-private-message.tsx index 89ed759..8afd348 100644 --- a/src/shared/components/private_message/create-private-message.tsx +++ b/src/shared/components/private_message/create-private-message.tsx @@ -1,5 +1,4 @@ import { getRecipientIdFromProps, myAuth, setIsoData } from "@utils/app"; -import { isBrowser } from "@utils/browser"; import { RouteDataResponse } from "@utils/types"; import { Component } from "inferno"; import { @@ -45,7 +44,7 @@ export class CreatePrivateMessage extends Component< this.handlePrivateMessageCreate.bind(this); // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { this.state = { ...this.state, recipientRes: this.isoData.routeData.recipientDetailsResponse, diff --git a/src/shared/components/search.tsx b/src/shared/components/search.tsx index 3d04c50..473b18c 100644 --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@ -11,11 +11,7 @@ import { setIsoData, showLocal, } from "@utils/app"; -import { - isBrowser, - restoreScrollPosition, - saveScrollPosition, -} from "@utils/browser"; +import { restoreScrollPosition, saveScrollPosition } from "@utils/browser"; import { capitalizeFirstLetter, debounce, @@ -274,7 +270,7 @@ export class Search extends Component { }; // Only fetch the data if coming from another route - if (!isBrowser() || FirstLoadService.isFirstLoad) { + if (FirstLoadService.isFirstLoad) { const { communityResponse: communityRes, creatorDetailsResponse: creatorDetailsRes, diff --git a/src/shared/services/FirstLoadService.ts b/src/shared/services/FirstLoadService.ts index b7558ef..926e3ac 100644 --- a/src/shared/services/FirstLoadService.ts +++ b/src/shared/services/FirstLoadService.ts @@ -1,3 +1,5 @@ +import { isBrowser } from "@utils/browser"; + export class FirstLoadService { #isFirstLoad: boolean; static #instance: FirstLoadService; @@ -20,6 +22,6 @@ export class FirstLoadService { } static get isFirstLoad() { - return this.#Instance.isFirstLoad; + return !isBrowser() || this.#Instance.isFirstLoad; } }