import { Helmet } from 'inferno-helmet';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
+import { DataType } from '../interfaces';
import {
UserOperation,
Community as CommunityI,
GetPostsForm,
GetCommunityForm,
ListingType,
- DataType,
GetPostsResponse,
PostResponse,
AddModToCommunityResponse,
WebSocketJsonResponse,
GetSiteResponse,
Site,
-} from '../interfaces';
+} from 'lemmy-js-client';
import { WebSocketService } from '../services';
import { PostListings } from './post-listings';
import { CommentNodes } from './comment-nodes';
commentsToFlatNodes,
setupTippy,
favIconUrl,
+ notifyPost,
} from '../utils';
import { i18n } from '../i18next';
interface UrlParams {
dataType?: string;
- sort?: string;
+ sort?: SortType;
page?: number;
}
}
get favIcon(): string {
- return this.state.community.icon
- ? this.state.community.icon
- : this.state.site.icon
- ? this.state.site.icon
- : favIconUrl;
+ return this.state.site.icon ? this.state.site.icon : favIconUrl;
}
render() {
<SortSelect sort={this.state.sort} onChange={this.handleSortChange} />
</span>
<a
- href={`/feeds/c/${this.state.communityName}.xml?sort=${
- SortType[this.state.sort]
- }`}
+ href={`/feeds/c/${this.state.communityName}.xml?sort=${this.state.sort}`}
target="_blank"
title="RSS"
rel="noopener"
}
handleSortChange(val: SortType) {
- this.updateUrl({ sort: SortType[val].toLowerCase(), page: 1 });
+ this.updateUrl({ sort: val, page: 1 });
window.scrollTo(0, 0);
}
handleDataTypeChange(val: DataType) {
- this.updateUrl({ dataType: DataType[val].toLowerCase(), page: 1 });
+ this.updateUrl({ dataType: DataType[val], page: 1 });
window.scrollTo(0, 0);
}
updateUrl(paramUpdates: UrlParams) {
- const dataTypeStr =
- paramUpdates.dataType || DataType[this.state.dataType].toLowerCase();
- const sortStr =
- paramUpdates.sort || SortType[this.state.sort].toLowerCase();
+ const dataTypeStr = paramUpdates.dataType || DataType[this.state.dataType];
+ const sortStr = paramUpdates.sort || this.state.sort;
const page = paramUpdates.page || this.state.page;
this.props.history.push(
`/c/${this.state.community.name}/data_type/${dataTypeStr}/sort/${sortStr}/page/${page}`
let getPostsForm: GetPostsForm = {
page: this.state.page,
limit: fetchLimit,
- sort: SortType[this.state.sort],
- type_: ListingType[ListingType.Community],
+ sort: this.state.sort,
+ type_: ListingType.Community,
community_id: this.state.community.id,
};
WebSocketService.Instance.getPosts(getPostsForm);
let getCommentsForm: GetCommentsForm = {
page: this.state.page,
limit: fetchLimit,
- sort: SortType[this.state.sort],
- type_: ListingType[ListingType.Community],
+ sort: this.state.sort,
+ type_: ListingType.Community,
community_id: this.state.community.id,
};
WebSocketService.Instance.getComments(getCommentsForm);
} else if (res.op == UserOperation.CreatePost) {
let data = res.data as PostResponse;
this.state.posts.unshift(data.post);
+ notifyPost(data.post, this.context.router);
this.setState(this.state);
} else if (res.op == UserOperation.CreatePostLike) {
let data = res.data as PostResponse;