mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-30 00:01:15 +00:00
Moved !isBrowser()
check to FirstLoadServer.isFirstLoad
This commit is contained in:
parent
c627678acd
commit
9aef820542
15 changed files with 19 additions and 36 deletions
|
@ -5,7 +5,6 @@ import {
|
||||||
setIsoData,
|
setIsoData,
|
||||||
showLocal,
|
showLocal,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import {
|
import {
|
||||||
getPageFromString,
|
getPageFromString,
|
||||||
getQueryParams,
|
getQueryParams,
|
||||||
|
@ -68,7 +67,7 @@ export class Communities extends Component<any, CommunitiesState> {
|
||||||
this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
|
this.handleListingTypeChange = this.handleListingTypeChange.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { listCommunitiesResponse } = this.isoData.routeData;
|
const { listCommunitiesResponse } = this.isoData.routeData;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
updateCommunityBlock,
|
updateCommunityBlock,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import {
|
import {
|
||||||
getPageFromString,
|
getPageFromString,
|
||||||
getQueryParams,
|
getQueryParams,
|
||||||
|
@ -198,7 +197,7 @@ export class Community extends Component<
|
||||||
this.handleFeaturePost = this.handleFeaturePost.bind(this);
|
this.handleFeaturePost = this.handleFeaturePost.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { communityRes, commentsRes, postsRes } = this.isoData.routeData;
|
const { communityRes, commentsRes, postsRes } = this.isoData.routeData;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
setIsoData,
|
setIsoData,
|
||||||
showLocal,
|
showLocal,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { capitalizeFirstLetter } from "@utils/helpers";
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
@ -75,7 +74,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
this.handleCreateEmoji = this.handleCreateEmoji.bind(this);
|
this.handleCreateEmoji = this.handleCreateEmoji.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { bannedRes, instancesRes } = this.isoData.routeData;
|
const { bannedRes, instancesRes } = this.isoData.routeData;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
showLocal,
|
showLocal,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import {
|
import {
|
||||||
getPageFromString,
|
getPageFromString,
|
||||||
getQueryParams,
|
getQueryParams,
|
||||||
|
@ -264,7 +263,7 @@ export class Home extends Component<any, HomeState> {
|
||||||
this.handleFeaturePost = this.handleFeaturePost.bind(this);
|
this.handleFeaturePost = this.handleFeaturePost.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { trendingCommunitiesRes, commentsRes, postsRes } =
|
const { trendingCommunitiesRes, commentsRes, postsRes } =
|
||||||
this.isoData.routeData;
|
this.isoData.routeData;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
import {
|
import {
|
||||||
|
@ -36,7 +35,7 @@ export class Instances extends Component<any, InstancesState> {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
this.state = {
|
this.state = {
|
||||||
...this.state,
|
...this.state,
|
||||||
instancesRes: this.isoData.routeData.federatedInstancesResponse,
|
instancesRes: this.isoData.routeData.federatedInstancesResponse,
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
personToChoice,
|
personToChoice,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import {
|
import {
|
||||||
debounce,
|
debounce,
|
||||||
getIdFromString,
|
getIdFromString,
|
||||||
|
@ -661,7 +660,7 @@ export class Modlog extends Component<
|
||||||
this.handleModChange = this.handleModChange.bind(this);
|
this.handleModChange = this.handleModChange.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { res, communityRes, modUserResponse, userResponse } =
|
const { res, communityRes, modUserResponse, userResponse } =
|
||||||
this.isoData.routeData;
|
this.isoData.routeData;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
setIsoData,
|
setIsoData,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import {
|
import {
|
||||||
|
@ -164,7 +163,7 @@ export class Inbox extends Component<any, InboxState> {
|
||||||
this.handleEditMessage = this.handleEditMessage.bind(this);
|
this.handleEditMessage = this.handleEditMessage.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { mentionsRes, messagesRes, repliesRes } = this.isoData.routeData;
|
const { mentionsRes, messagesRes, repliesRes } = this.isoData.routeData;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -10,11 +10,7 @@ import {
|
||||||
setIsoData,
|
setIsoData,
|
||||||
updatePersonBlock,
|
updatePersonBlock,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import {
|
import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
|
||||||
isBrowser,
|
|
||||||
restoreScrollPosition,
|
|
||||||
saveScrollPosition,
|
|
||||||
} from "@utils/browser";
|
|
||||||
import {
|
import {
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
futureDaysToUnixTime,
|
futureDaysToUnixTime,
|
||||||
|
@ -210,7 +206,7 @@ export class Profile extends Component<
|
||||||
this.handleFeaturePost = this.handleFeaturePost.bind(this);
|
this.handleFeaturePost = this.handleFeaturePost.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
this.state = {
|
this.state = {
|
||||||
...this.state,
|
...this.state,
|
||||||
personRes: this.isoData.routeData.personResponse,
|
personRes: this.isoData.routeData.personResponse,
|
||||||
|
|
|
@ -3,7 +3,6 @@ import {
|
||||||
myAuthRequired,
|
myAuthRequired,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import {
|
import {
|
||||||
|
@ -59,7 +58,7 @@ export class RegistrationApplications extends Component<
|
||||||
this.handleApproveApplication = this.handleApproveApplication.bind(this);
|
this.handleApproveApplication = this.handleApproveApplication.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
this.state = {
|
this.state = {
|
||||||
...this.state,
|
...this.state,
|
||||||
appsRes: this.isoData.routeData.listRegistrationApplicationsResponse,
|
appsRes: this.isoData.routeData.listRegistrationApplicationsResponse,
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
myAuthRequired,
|
myAuthRequired,
|
||||||
setIsoData,
|
setIsoData,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { amAdmin } from "@utils/roles";
|
import { amAdmin } from "@utils/roles";
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
|
@ -109,7 +108,7 @@ export class Reports extends Component<any, ReportsState> {
|
||||||
this.handleResolvePrivateMessageReport.bind(this);
|
this.handleResolvePrivateMessageReport.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { commentReportsRes, postReportsRes, messageReportsRes } =
|
const { commentReportsRes, postReportsRes, messageReportsRes } =
|
||||||
this.isoData.routeData;
|
this.isoData.routeData;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { enableDownvotes, enableNsfw, myAuth, setIsoData } from "@utils/app";
|
import { enableDownvotes, enableNsfw, myAuth, setIsoData } from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { getIdFromString, getQueryParams } from "@utils/helpers";
|
import { getIdFromString, getQueryParams } from "@utils/helpers";
|
||||||
import type { QueryParams } from "@utils/types";
|
import type { QueryParams } from "@utils/types";
|
||||||
import { Choice, RouteDataResponse } from "@utils/types";
|
import { Choice, RouteDataResponse } from "@utils/types";
|
||||||
|
@ -70,7 +69,7 @@ export class CreatePost extends Component<
|
||||||
this.handleSelectedCommunityChange.bind(this);
|
this.handleSelectedCommunityChange.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { communityResponse: communityRes, initialCommunitiesRes } =
|
const { communityResponse: communityRes, initialCommunitiesRes } =
|
||||||
this.isoData.routeData;
|
this.isoData.routeData;
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ export class Post extends Component<any, PostState> {
|
||||||
this.state = { ...this.state, commentSectionRef: createRef() };
|
this.state = { ...this.state, commentSectionRef: createRef() };
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const { commentsRes, postRes } = this.isoData.routeData;
|
const { commentsRes, postRes } = this.isoData.routeData;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { getRecipientIdFromProps, myAuth, setIsoData } from "@utils/app";
|
import { getRecipientIdFromProps, myAuth, setIsoData } from "@utils/app";
|
||||||
import { isBrowser } from "@utils/browser";
|
|
||||||
import { RouteDataResponse } from "@utils/types";
|
import { RouteDataResponse } from "@utils/types";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
import {
|
import {
|
||||||
|
@ -45,7 +44,7 @@ export class CreatePrivateMessage extends Component<
|
||||||
this.handlePrivateMessageCreate.bind(this);
|
this.handlePrivateMessageCreate.bind(this);
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
this.state = {
|
this.state = {
|
||||||
...this.state,
|
...this.state,
|
||||||
recipientRes: this.isoData.routeData.recipientDetailsResponse,
|
recipientRes: this.isoData.routeData.recipientDetailsResponse,
|
||||||
|
|
|
@ -11,11 +11,7 @@ import {
|
||||||
setIsoData,
|
setIsoData,
|
||||||
showLocal,
|
showLocal,
|
||||||
} from "@utils/app";
|
} from "@utils/app";
|
||||||
import {
|
import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
|
||||||
isBrowser,
|
|
||||||
restoreScrollPosition,
|
|
||||||
saveScrollPosition,
|
|
||||||
} from "@utils/browser";
|
|
||||||
import {
|
import {
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
debounce,
|
debounce,
|
||||||
|
@ -274,7 +270,7 @@ export class Search extends Component<any, SearchState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only fetch the data if coming from another route
|
// Only fetch the data if coming from another route
|
||||||
if (!isBrowser() || FirstLoadService.isFirstLoad) {
|
if (FirstLoadService.isFirstLoad) {
|
||||||
const {
|
const {
|
||||||
communityResponse: communityRes,
|
communityResponse: communityRes,
|
||||||
creatorDetailsResponse: creatorDetailsRes,
|
creatorDetailsResponse: creatorDetailsRes,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { isBrowser } from "@utils/browser";
|
||||||
|
|
||||||
export class FirstLoadService {
|
export class FirstLoadService {
|
||||||
#isFirstLoad: boolean;
|
#isFirstLoad: boolean;
|
||||||
static #instance: FirstLoadService;
|
static #instance: FirstLoadService;
|
||||||
|
@ -20,6 +22,6 @@ export class FirstLoadService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static get isFirstLoad() {
|
static get isFirstLoad() {
|
||||||
return this.#Instance.isFirstLoad;
|
return !isBrowser() || this.#Instance.isFirstLoad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue