"eslint": "^7.20.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^5.1.0",
- "lemmy-js-client": "0.9.9",
+ "lemmy-js-client": "0.10.0-rc.1",
"lint-staged": "^10.5.4",
"mini-css-extract-plugin": "^1.3.8",
"node-fetch": "^2.6.1",
<thead class="pointer">
<tr>
<th>{i18n.t("name")}</th>
- <th>{i18n.t("category")}</th>
<th class="text-right">{i18n.t("subscribers")}</th>
<th class="text-right">
{i18n.t("users")} / {i18n.t("month")}
<td>
<CommunityLink community={cv.community} />
</td>
- <td>{cv.category.name}</td>
<td class="text-right">{cv.counts.subscribers}</td>
<td class="text-right">{cv.counts.users_active_month}</td>
<td class="text-right d-none d-lg-table-cell">
EditCommunity,
CreateCommunity,
UserOperation,
- Category,
CommunityResponse,
CommunityView,
} from "lemmy-js-client";
interface CommunityFormProps {
community_view?: CommunityView; // If a community is given, that means this is an edit
- categories: Category[];
onCancel?(): any;
onCreate?(community: CommunityView): any;
onEdit?(community: CommunityView): any;
communityForm: {
name: null,
title: null,
- category_id: this.props.categories[0].id,
nsfw: false,
icon: null,
banner: null,
this.state.communityForm = {
name: cv.community.name,
title: cv.community.title,
- category_id: cv.category.id,
description: cv.community.description,
nsfw: cv.community.nsfw,
icon: cv.community.icon,
/>
</div>
</div>
- <div class="form-group row">
- <label class="col-12 col-form-label" htmlFor="community-category">
- {i18n.t("category")}
- </label>
- <div class="col-12">
- <select
- class="form-control"
- id="community-category"
- value={this.state.communityForm.category_id}
- onInput={linkEvent(this, this.handleCommunityCategoryChange)}
- >
- {this.props.categories.map(category => (
- <option value={category.id}>{category.name}</option>
- ))}
- </select>
- </div>
- </div>
{this.props.enableNsfw && (
<div class="form-group row">
this.setState(this.state);
}
- handleCommunityCategoryChange(i: CommunityForm, event: any) {
- i.state.communityForm.category_id = Number(event.target.value);
- i.setState(i.state);
- }
-
handleCommunityNsfwChange(i: CommunityForm, event: any) {
i.state.communityForm.nsfw = event.target.checked;
i.setState(i.state);
GetCommentsResponse,
CommentResponse,
GetSiteResponse,
- Category,
- ListCategoriesResponse,
} from "lemmy-js-client";
import { UserService, WebSocketService } from "../services";
import { PostListings } from "./post-listings";
dataType: DataType;
sort: SortType;
page: number;
- categories: Category[];
}
interface CommunityProps {
sort: getSortTypeFromProps(this.props),
page: getPageFromProps(this.props),
siteRes: this.isoData.site_res,
- categories: [],
};
constructor(props: any, context: any) {
} else {
this.state.comments = this.isoData.routeData[1].comments;
}
- this.state.categories = this.isoData.routeData[2].categories;
this.state.communityLoading = false;
this.state.postsLoading = false;
this.state.commentsLoading = false;
} else {
this.fetchCommunity();
this.fetchData();
- WebSocketService.Instance.send(wsClient.listCategories());
}
setupTippy();
}
promises.push(req.client.getComments(getCommentsForm));
}
- promises.push(req.client.listCategories());
-
return promises;
}
admins={this.state.siteRes.admins}
online={this.state.communityRes.online}
enableNsfw={this.state.siteRes.site_view.site.enable_nsfw}
- categories={this.state.categories}
/>
</div>
</div>
let data = wsJsonToRes<CommentResponse>(msg).data;
createCommentLikeRes(data.comment_view, this.state.comments);
this.setState(this.state);
- } else if (op == UserOperation.ListCategories) {
- let data = wsJsonToRes<ListCategoriesResponse>(msg).data;
- this.state.categories = data.categories;
- this.setState(this.state);
}
}
}
import { Spinner } from "./icon";
import {
CommunityView,
- UserOperation,
SiteView,
- ListCategoriesResponse,
- Category,
} from "lemmy-js-client";
import {
setIsoData,
toast,
- wsJsonToRes,
wsSubscribe,
isBrowser,
- wsUserOp,
- wsClient,
} from "../utils";
-import { WebSocketService, UserService } from "../services";
+import { UserService } from "../services";
import { i18n } from "../i18next";
-import { InitialFetchRequest } from "shared/interfaces";
interface CreateCommunityState {
site_view: SiteView;
- categories: Category[];
loading: boolean;
}
private subscription: Subscription;
private emptyState: CreateCommunityState = {
site_view: this.isoData.site_res.site_view,
- categories: [],
loading: true,
};
constructor(props: any, context: any) {
// Only fetch the data if coming from another route
if (this.isoData.path == this.context.router.route.match.url) {
- this.state.categories = this.isoData.routeData[0].categories;
this.state.loading = false;
- } else {
- WebSocketService.Instance.send(wsClient.listCategories());
}
}
<div class="col-12 col-lg-6 offset-lg-3 mb-4">
<h5>{i18n.t("create_community")}</h5>
<CommunityForm
- categories={this.state.categories}
onCreate={this.handleCommunityCreate}
enableNsfw={this.state.site_view.site.enable_nsfw}
/>
this.props.history.push(`/c/${cv.community.name}`);
}
- static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
- return [req.client.listCategories()];
- }
-
parseMessage(msg: any) {
- let op = wsUserOp(msg);
if (msg.error) {
// Toast errors are already handled by community-form
return;
- } else if (op == UserOperation.ListCategories) {
- let data = wsJsonToRes<ListCategoriesResponse>(msg).data;
- this.state.categories = data.categories;
- this.state.loading = false;
- this.setState(this.state);
}
}
}
SearchResponse,
GetSiteResponse,
GetCommunityResponse,
- ListCategoriesResponse,
- Category,
} from "lemmy-js-client";
import {
CommentSortType,
loading: boolean;
crossPosts: PostView[];
siteRes: GetSiteResponse;
- categories: Category[];
}
export class Post extends Component<any, PostState> {
loading: true,
crossPosts: [],
siteRes: this.isoData.site_res,
- categories: [],
};
constructor(props: any, context: any) {
this.state.postRes.comments,
this.state.commentSort
);
- this.state.categories = this.isoData.routeData[1].categories;
this.state.loading = false;
if (isBrowser()) {
}
} else {
this.fetchPost();
- WebSocketService.Instance.send(wsClient.listCategories());
}
}
setOptionalAuth(postForm, req.auth);
promises.push(req.client.getPost(postForm));
- promises.push(req.client.listCategories());
return promises;
}
online={this.state.postRes.online}
enableNsfw={this.state.siteRes.site_view.site.enable_nsfw}
showIcon
- categories={this.state.categories}
/>
</div>
);
this.state.postRes.post_view.community = data.community_view.community;
this.state.postRes.moderators = data.moderators;
this.setState(this.state);
- } else if (op == UserOperation.ListCategories) {
- let data = wsJsonToRes<ListCategoriesResponse>(msg).data;
- this.state.categories = data.categories;
- this.setState(this.state);
}
}
}
RemoveCommunity,
UserViewSafe,
AddModToCommunity,
- Category,
} from "lemmy-js-client";
import { WebSocketService, UserService } from "../services";
import { mdToHtml, getUnixTime, wsClient, authField } from "../utils";
interface SidebarProps {
community_view: CommunityView;
- categories: Category[];
moderators: CommunityModeratorView[];
admins: UserViewSafe[];
online: number;
this.sidebar()
) : (
<CommunityForm
- categories={this.props.categories}
community_view={this.props.community_view}
onEdit={this.handleEditCommunity}
onCancel={this.handleEditCancel}
count: counts.comments,
})}
</li>
- <li className="list-inline-item">
- <Link className="badge badge-secondary" to="/communities">
- {community_view.category.name}
- </Link>
- </li>
<li className="list-inline-item">
<Link
className="badge badge-secondary"
{
path: `/create_community`,
component: CreateCommunity,
- fetchInitialData: req => CreateCommunity.fetchInitialData(req),
},
{
path: `/create_private_message/recipient/:recipient_id`,
dependencies:
invert-kv "^1.0.0"
-lemmy-js-client@0.9.9:
- version "0.9.9"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.9.9.tgz#cd1effe165147d04da93d1265e30dd1daf09c0de"
- integrity sha512-+tHghqb02WM/Deizneg/8wO6W6ZqG67y5gZwZb9QQLDcowLZWTmFCwdoYVxLxcH6LBmZ1TvPq7ppumB5vQI1qg==
+lemmy-js-client@0.10.0-rc.1:
+ version "0.10.0-rc.1"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.10.0-rc.1.tgz#4a9b9db8fcc8229d634920d7e66f63ab5db8b28e"
+ integrity sha512-18TQO+EpE+mgCWSwynfFvDCASUjzTkr73/CbneMMHcqexq2R4donE+pNDFFSDHOeYIbdna0f4GZEJhyeh6826g==
levn@^0.4.1:
version "0.4.1"