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';
import { SiteForm } from './site-form';
import { UserListing } from './user-listing';
import { CommunityLink } from './community-link';
+import { BannerIconHeader } from './banner-icon-header';
import {
wsJsonToRes,
repoUrl,
editPostFindRes,
commentsToFlatNodes,
setupTippy,
+ favIconUrl,
+ notifyPost,
} from '../utils';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';
}
interface UrlParams {
- listingType?: string;
+ listingType?: ListingType;
dataType?: string;
- sort?: string;
+ sort?: SortType;
page?: number;
}
enable_downvotes: null,
open_registration: null,
enable_nsfw: null,
+ icon: null,
+ banner: null,
+ creator_preferred_username: null,
},
admins: [],
banned: [],
online: null,
version: null,
+ federated_instances: null,
},
showEditSite: false,
loading: true,
}
let listCommunitiesForm: ListCommunitiesForm = {
- sort: SortType[SortType.Hot],
+ sort: SortType.Hot,
limit: 6,
};
}
}
+ get favIcon(): string {
+ return this.state.siteRes.site.icon
+ ? this.state.siteRes.site.icon
+ : favIconUrl;
+ }
+
render() {
return (
<div class="container">
- <Helmet title={this.documentTitle} />
+ <Helmet title={this.documentTitle}>
+ <link
+ id="favicon"
+ rel="icon"
+ type="image/x-icon"
+ href={this.favIcon}
+ />
+ </Helmet>
<div class="row">
<main role="main" class="col-12 col-md-8">
{this.posts()}
<div>
<div class="card bg-transparent border-secondary mb-3">
<div class="card-header bg-transparent border-secondary">
- {this.siteName()}
- {this.adminButtons()}
+ <div class="mb-2">
+ {this.siteName()}
+ {this.adminButtons()}
+ </div>
+ <BannerIconHeader banner={this.state.siteRes.site.banner} />
</div>
<div class="card-body">
{this.trendingCommunities()}
id: community.community_id,
local: community.community_local,
actor_id: community.community_actor_id,
+ icon: community.community_icon,
}}
/>
</li>
}
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}`
<UserListing
user={{
name: admin.name,
+ preferred_username: admin.preferred_username,
avatar: admin.avatar,
local: admin.local,
actor_id: admin.actor_id,
badges() {
return (
<ul class="my-2 list-inline">
- {/*
- <li className="list-inline-item badge badge-light">
- {i18n.t('number_online', { count: this.state.siteRes.online })}
- </li>
- */}
+ <li className="list-inline-item badge badge-light">
+ {i18n.t('number_online', { count: this.state.siteRes.online })}
+ </li>
<li className="list-inline-item badge badge-light">
{i18n.t('number_of_users', {
count: this.state.siteRes.site.number_of_users,
<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);
}
.includes(data.post.community_id)
) {
this.state.posts.unshift(data.post);
+ notifyPost(data.post, this.context.router);
}
} else {
// NSFW posts
UserService.Instance.user.show_nsfw)
) {
this.state.posts.unshift(data.post);
+ notifyPost(data.post, this.context.router);
}
}
this.setState(this.state);