import { FirstLoadService } from "../../services/FirstLoadService";
import { HttpService, RequestState } from "../../services/HttpService";
import {
- canCreateCommunity,
commentsToFlatNodes,
editComment,
editPost,
getCommentParentId,
getDataTypeString,
getPageFromString,
- getQueryParams,
- getQueryString,
getRandomFromList,
mdToHtml,
myAuth,
postToCommentSortType,
- QueryParams,
relTags,
restoreScrollPosition,
saveScrollPosition,
trendingFetchLimit,
updatePersonBlock,
} from "../../utils";
+import { getQueryParams } from "../../utils/helpers/get-query-params";
+import { getQueryString } from "../../utils/helpers/get-query-string";
+import { canCreateCommunity } from "../../utils/roles/can-create-community";
+import type { QueryParams } from "../../utils/types/query-params";
import { CommentNodes } from "../comment/comment-nodes";
import { DataTypeSelect } from "../common/data-type-select";
import { HtmlTags } from "../common/html-tags";
}
async componentDidMount() {
- if (!this.state.isIsomorphic) {
+ if (!this.state.isIsomorphic || !this.isoData.routeData.length) {
await Promise.all([this.fetchTrendingCommunities(), this.fetchData()]);
}
+
setupTippy();
}
siteRes: {
site_view: { counts, site },
admins,
- online,
},
showSubscribedMobile,
showTrendingMobile,
site={site}
admins={admins}
counts={counts}
- online={online}
showLocal={showLocal(this.isoData)}
/>
)}
siteRes: {
site_view: { counts, site },
admins,
- online,
},
} = this.state;
return (
- <div>
- <div>
- <div className="card border-secondary mb-3">
- <div className="card-body">
- {this.trendingCommunities()}
- {canCreateCommunity(this.state.siteRes) && (
- <LinkButton
- path="/create_community"
- translationKey="create_a_community"
- />
- )}
+ <div id="sidebarContainer">
+ <section id="sidebarMain" className="card border-secondary mb-3">
+ <div className="card-body">
+ {this.trendingCommunities()}
+ {canCreateCommunity(this.state.siteRes) && (
<LinkButton
- path="/communities"
- translationKey="explore_communities"
+ path="/create_community"
+ translationKey="create_a_community"
/>
- </div>
+ )}
+ <LinkButton
+ path="/communities"
+ translationKey="explore_communities"
+ />
</div>
- <SiteSidebar
- site={site}
- admins={admins}
- counts={counts}
- online={online}
- showLocal={showLocal(this.isoData)}
- />
- {this.hasFollows && (
- <div className="card border-secondary mb-3">
- <div className="card-body">{this.subscribedCommunities}</div>
- </div>
- )}
- </div>
+ </section>
+ <SiteSidebar
+ site={site}
+ admins={admins}
+ counts={counts}
+ showLocal={showLocal(this.isoData)}
+ />
+ {this.hasFollows && (
+ <section
+ id="sidebarSubscribed"
+ className="card border-secondary mb-3"
+ >
+ <div className="card-body">{this.subscribedCommunities}</div>
+ </section>
+ )}
</div>
);
}
trendingCommunities(isMobile = false) {
- switch (this.state.trendingCommunitiesRes.state) {
+ switch (this.state.trendingCommunitiesRes?.state) {
case "loading":
return (
<h5>
const siteRes = this.state.siteRes;
if (dataType === DataType.Post) {
- switch (this.state.postsRes.state) {
+ switch (this.state.postsRes?.state) {
case "loading":
return (
<h5>