SortType,
GetSiteResponse,
ListingType,
- DataType,
SiteResponse,
GetPostsResponse,
PostResponse,
AddAdminResponse,
BanUserResponse,
WebSocketJsonResponse,
-} from '../interfaces';
+} from 'lemmy-js-client';
+import { DataType } from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { PostListings } from './post-listings';
import { CommentNodes } from './comment-nodes';
}
interface UrlParams {
- listingType?: string;
+ listingType?: ListingType;
dataType?: string;
- sort?: string;
+ sort?: SortType;
page?: number;
}
}
let listCommunitiesForm: ListCommunitiesForm = {
- sort: SortType[SortType.Hot],
+ sort: SortType.Hot,
limit: 6,
};
}
updateUrl(paramUpdates: UrlParams) {
- const listingTypeStr =
- paramUpdates.listingType ||
- ListingType[this.state.listingType].toLowerCase();
- const dataTypeStr =
- paramUpdates.dataType || DataType[this.state.dataType].toLowerCase();
- const sortStr =
- paramUpdates.sort || SortType[this.state.sort].toLowerCase();
+ const listingTypeStr = paramUpdates.listingType || this.state.listingType;
+ 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(
`/home/data_type/${dataTypeStr}/listing_type/${listingTypeStr}/sort/${sortStr}/page/${page}`
<span class="mr-3">
<ListingTypeSelect
type_={this.state.listingType}
+ showLocal={
+ this.state.siteRes.federated_instances &&
+ this.state.siteRes.federated_instances.length > 0
+ }
onChange={this.handleListingTypeChange}
/>
</span>
</span>
{this.state.listingType == ListingType.All && (
<a
- href={`/feeds/all.xml?sort=${SortType[this.state.sort]}`}
+ href={`/feeds/all.xml?sort=${this.state.sort}`}
target="_blank"
rel="noopener"
title="RSS"
{UserService.Instance.user &&
this.state.listingType == ListingType.Subscribed && (
<a
- href={`/feeds/front/${UserService.Instance.auth}.xml?sort=${
- SortType[this.state.sort]
- }`}
+ href={`/feeds/front/${UserService.Instance.auth}.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);
}
handleListingTypeChange(val: ListingType) {
- this.updateUrl({ listingType: ListingType[val].toLowerCase(), page: 1 });
+ this.updateUrl({ listingType: 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);
}
let getPostsForm: GetPostsForm = {
page: this.state.page,
limit: fetchLimit,
- sort: SortType[this.state.sort],
- type_: ListingType[this.state.listingType],
+ sort: this.state.sort,
+ type_: this.state.listingType,
};
WebSocketService.Instance.getPosts(getPostsForm);
} else {
let getCommentsForm: GetCommentsForm = {
page: this.state.page,
limit: fetchLimit,
- sort: SortType[this.state.sort],
- type_: ListingType[this.state.listingType],
+ sort: this.state.sort,
+ type_: this.state.listingType,
};
WebSocketService.Instance.getComments(getCommentsForm);
}