mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 13:51:13 +00:00
This commit is contained in:
parent
f245d2b517
commit
fc234716b0
4 changed files with 51 additions and 21 deletions
|
@ -253,8 +253,10 @@ export class Community extends Component<
|
|||
|
||||
const sort = getSortTypeFromQuery(urlSort);
|
||||
|
||||
let postsResponse: RequestState<GetPostsResponse> = EMPTY_REQUEST;
|
||||
let commentsResponse: RequestState<GetCommentsResponse> = EMPTY_REQUEST;
|
||||
let postsFetch: Promise<RequestState<GetPostsResponse>> =
|
||||
Promise.resolve(EMPTY_REQUEST);
|
||||
let commentsFetch: Promise<RequestState<GetCommentsResponse>> =
|
||||
Promise.resolve(EMPTY_REQUEST);
|
||||
|
||||
if (dataType === DataType.Post) {
|
||||
const getPostsForm: GetPosts = {
|
||||
|
@ -266,7 +268,7 @@ export class Community extends Component<
|
|||
saved_only: false,
|
||||
};
|
||||
|
||||
postsResponse = await client.getPosts(getPostsForm);
|
||||
postsFetch = client.getPosts(getPostsForm);
|
||||
} else {
|
||||
const getCommentsForm: GetComments = {
|
||||
community_name: communityName,
|
||||
|
@ -276,13 +278,21 @@ export class Community extends Component<
|
|||
saved_only: false,
|
||||
};
|
||||
|
||||
commentsResponse = await client.getComments(getCommentsForm);
|
||||
commentsFetch = client.getComments(getCommentsForm);
|
||||
}
|
||||
|
||||
const communityFetch = client.getCommunity(communityForm);
|
||||
|
||||
const [communityRes, commentsRes, postsRes] = await Promise.all([
|
||||
communityFetch,
|
||||
commentsFetch,
|
||||
postsFetch,
|
||||
]);
|
||||
|
||||
return {
|
||||
communityRes: await client.getCommunity(communityForm),
|
||||
commentsRes: commentsResponse,
|
||||
postsRes: postsResponse,
|
||||
communityRes,
|
||||
commentsRes,
|
||||
postsRes,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -323,8 +323,10 @@ export class Home extends Component<any, HomeState> {
|
|||
site.site_view.local_site.default_post_listing_type;
|
||||
const sort = getSortTypeFromQuery(urlSort, site.my_user);
|
||||
|
||||
let postsRes: RequestState<GetPostsResponse> = EMPTY_REQUEST;
|
||||
let commentsRes: RequestState<GetCommentsResponse> = EMPTY_REQUEST;
|
||||
let postsFetch: Promise<RequestState<GetPostsResponse>> =
|
||||
Promise.resolve(EMPTY_REQUEST);
|
||||
let commentsFetch: Promise<RequestState<GetCommentsResponse>> =
|
||||
Promise.resolve(EMPTY_REQUEST);
|
||||
|
||||
if (dataType === DataType.Post) {
|
||||
const getPostsForm: GetPosts = {
|
||||
|
@ -335,7 +337,7 @@ export class Home extends Component<any, HomeState> {
|
|||
saved_only: false,
|
||||
};
|
||||
|
||||
postsRes = await client.getPosts(getPostsForm);
|
||||
postsFetch = client.getPosts(getPostsForm);
|
||||
} else {
|
||||
const getCommentsForm: GetComments = {
|
||||
limit: fetchLimit,
|
||||
|
@ -344,7 +346,7 @@ export class Home extends Component<any, HomeState> {
|
|||
saved_only: false,
|
||||
};
|
||||
|
||||
commentsRes = await client.getComments(getCommentsForm);
|
||||
commentsFetch = client.getComments(getCommentsForm);
|
||||
}
|
||||
|
||||
const trendingCommunitiesForm: ListCommunities = {
|
||||
|
@ -353,10 +355,18 @@ export class Home extends Component<any, HomeState> {
|
|||
limit: trendingFetchLimit,
|
||||
};
|
||||
|
||||
const trendingCommunitiesFetch = client.listCommunities(
|
||||
trendingCommunitiesForm,
|
||||
);
|
||||
|
||||
const [postsRes, commentsRes, trendingCommunitiesRes] = await Promise.all([
|
||||
postsFetch,
|
||||
commentsFetch,
|
||||
trendingCommunitiesFetch,
|
||||
]);
|
||||
|
||||
return {
|
||||
trendingCommunitiesRes: await client.listCommunities(
|
||||
trendingCommunitiesForm,
|
||||
),
|
||||
trendingCommunitiesRes,
|
||||
commentsRes,
|
||||
postsRes,
|
||||
};
|
||||
|
|
|
@ -165,16 +165,21 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
|||
constructor(props: any, context: any) {
|
||||
super(props, context);
|
||||
|
||||
if (UserService.Instance.myUserInfo) {
|
||||
this.state.imageExpanded =
|
||||
UserService.Instance.myUserInfo.local_user_view.local_user.auto_expand;
|
||||
}
|
||||
|
||||
this.handleEditPost = this.handleEditPost.bind(this);
|
||||
this.handleEditCancel = this.handleEditCancel.bind(this);
|
||||
this.handleReportSubmit = this.handleReportSubmit.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
if (UserService.Instance.myUserInfo) {
|
||||
this.setState({
|
||||
imageExpanded:
|
||||
UserService.Instance.myUserInfo.local_user_view.local_user
|
||||
.auto_expand,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: PostListingProps) {
|
||||
if (this.props !== nextProps) {
|
||||
this.setState({
|
||||
|
|
|
@ -263,9 +263,14 @@ export class Post extends Component<any, PostState> {
|
|||
commentsForm.parent_id = id;
|
||||
}
|
||||
|
||||
const [postRes, commentsRes] = await Promise.all([
|
||||
client.getPost(postForm),
|
||||
client.getComments(commentsForm),
|
||||
]);
|
||||
|
||||
return {
|
||||
postRes: await client.getPost(postForm),
|
||||
commentsRes: await client.getComments(commentsForm),
|
||||
postRes,
|
||||
commentsRes,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue