From: Felix Ableitner Date: Wed, 3 Mar 2021 16:59:57 +0000 (+0100) Subject: Remove categories X-Git-Url: http://these/git/?a=commitdiff_plain;h=e02075d52d5c6adb45169b0db472b5b8d317a9e2;hp=cc215fe99f66257373b7ad178cec0457d1214ecd;p=lemmy-ui.git Remove categories --- diff --git a/package.json b/package.json index e427117..96fd0c2 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "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", diff --git a/src/shared/components/communities.tsx b/src/shared/components/communities.tsx index def03df..74a1ac3 100644 --- a/src/shared/components/communities.tsx +++ b/src/shared/components/communities.tsx @@ -124,7 +124,6 @@ export class Communities extends Component { {i18n.t("name")} - {i18n.t("category")} {i18n.t("subscribers")} {i18n.t("users")} / {i18n.t("month")} @@ -144,7 +143,6 @@ export class Communities extends Component { - {cv.category.name} {cv.counts.subscribers} {cv.counts.users_active_month} diff --git a/src/shared/components/community-form.tsx b/src/shared/components/community-form.tsx index 5b8034c..97d335e 100644 --- a/src/shared/components/community-form.tsx +++ b/src/shared/components/community-form.tsx @@ -5,7 +5,6 @@ import { EditCommunity, CreateCommunity, UserOperation, - Category, CommunityResponse, CommunityView, } from "lemmy-js-client"; @@ -28,7 +27,6 @@ import { Icon, Spinner } from "./icon"; 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; @@ -51,7 +49,6 @@ export class CommunityForm extends Component< communityForm: { name: null, title: null, - category_id: this.props.categories[0].id, nsfw: false, icon: null, banner: null, @@ -80,7 +77,6 @@ export class CommunityForm extends Component< 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, @@ -205,23 +201,6 @@ export class CommunityForm extends Component< /> -
- -
- -
-
{this.props.enableNsfw && (
@@ -304,11 +283,6 @@ export class CommunityForm extends Component< 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); diff --git a/src/shared/components/community.tsx b/src/shared/components/community.tsx index ef5c783..9f492cd 100644 --- a/src/shared/components/community.tsx +++ b/src/shared/components/community.tsx @@ -19,8 +19,6 @@ import { GetCommentsResponse, CommentResponse, GetSiteResponse, - Category, - ListCategoriesResponse, } from "lemmy-js-client"; import { UserService, WebSocketService } from "../services"; import { PostListings } from "./post-listings"; @@ -72,7 +70,6 @@ interface State { dataType: DataType; sort: SortType; page: number; - categories: Category[]; } interface CommunityProps { @@ -103,7 +100,6 @@ export class Community extends Component { sort: getSortTypeFromProps(this.props), page: getPageFromProps(this.props), siteRes: this.isoData.site_res, - categories: [], }; constructor(props: any, context: any) { @@ -124,14 +120,12 @@ export class Community extends Component { } 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(); } @@ -211,8 +205,6 @@ export class Community extends Component { promises.push(req.client.getComments(getCommentsForm)); } - promises.push(req.client.listCategories()); - return promises; } @@ -268,7 +260,6 @@ export class Community extends Component { admins={this.state.siteRes.admins} online={this.state.communityRes.online} enableNsfw={this.state.siteRes.site_view.site.enable_nsfw} - categories={this.state.categories} />
@@ -541,10 +532,6 @@ export class Community extends Component { let data = wsJsonToRes(msg).data; createCommentLikeRes(data.comment_view, this.state.comments); this.setState(this.state); - } else if (op == UserOperation.ListCategories) { - let data = wsJsonToRes(msg).data; - this.state.categories = data.categories; - this.setState(this.state); } } } diff --git a/src/shared/components/create-community.tsx b/src/shared/components/create-community.tsx index da44997..e1a9cf8 100644 --- a/src/shared/components/create-community.tsx +++ b/src/shared/components/create-community.tsx @@ -5,27 +5,19 @@ import { HtmlTags } from "./html-tags"; 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; } @@ -34,7 +26,6 @@ export class CreateCommunity extends Component { private subscription: Subscription; private emptyState: CreateCommunityState = { site_view: this.isoData.site_res.site_view, - categories: [], loading: true, }; constructor(props: any, context: any) { @@ -52,10 +43,7 @@ export class CreateCommunity extends Component { // 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()); } } @@ -85,7 +73,6 @@ export class CreateCommunity extends Component {
{i18n.t("create_community")}
@@ -100,20 +87,10 @@ export class CreateCommunity extends Component { this.props.history.push(`/c/${cv.community.name}`); } - static fetchInitialData(req: InitialFetchRequest): Promise[] { - 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(msg).data; - this.state.categories = data.categories; - this.state.loading = false; - this.setState(this.state); } } } diff --git a/src/shared/components/post.tsx b/src/shared/components/post.tsx index 6102499..b1bd9aa 100644 --- a/src/shared/components/post.tsx +++ b/src/shared/components/post.tsx @@ -21,8 +21,6 @@ import { SearchResponse, GetSiteResponse, GetCommunityResponse, - ListCategoriesResponse, - Category, } from "lemmy-js-client"; import { CommentSortType, @@ -74,7 +72,6 @@ interface PostState { loading: boolean; crossPosts: PostView[]; siteRes: GetSiteResponse; - categories: Category[]; } export class Post extends Component { @@ -91,7 +88,6 @@ export class Post extends Component { loading: true, crossPosts: [], siteRes: this.isoData.site_res, - categories: [], }; constructor(props: any, context: any) { @@ -109,7 +105,6 @@ export class Post extends Component { this.state.postRes.comments, this.state.commentSort ); - this.state.categories = this.isoData.routeData[1].categories; this.state.loading = false; if (isBrowser()) { @@ -120,7 +115,6 @@ export class Post extends Component { } } else { this.fetchPost(); - WebSocketService.Instance.send(wsClient.listCategories()); } } @@ -158,7 +152,6 @@ export class Post extends Component { setOptionalAuth(postForm, req.auth); promises.push(req.client.getPost(postForm)); - promises.push(req.client.listCategories()); return promises; } @@ -402,7 +395,6 @@ export class Post extends Component { online={this.state.postRes.online} enableNsfw={this.state.siteRes.site_view.site.enable_nsfw} showIcon - categories={this.state.categories} />
); @@ -570,10 +562,6 @@ export class Post extends Component { 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(msg).data; - this.state.categories = data.categories; - this.setState(this.state); } } } diff --git a/src/shared/components/sidebar.tsx b/src/shared/components/sidebar.tsx index 436d6cf..47de96d 100644 --- a/src/shared/components/sidebar.tsx +++ b/src/shared/components/sidebar.tsx @@ -8,7 +8,6 @@ import { RemoveCommunity, UserViewSafe, AddModToCommunity, - Category, } from "lemmy-js-client"; import { WebSocketService, UserService } from "../services"; import { mdToHtml, getUnixTime, wsClient, authField } from "../utils"; @@ -21,7 +20,6 @@ import { i18n } from "../i18next"; interface SidebarProps { community_view: CommunityView; - categories: Category[]; moderators: CommunityModeratorView[]; admins: UserViewSafe[]; online: number; @@ -60,7 +58,6 @@ export class Sidebar extends Component { this.sidebar() ) : ( { count: counts.comments, })} -
  • - - {community_view.category.name} - -
  • CreateCommunity.fetchInitialData(req), }, { path: `/create_private_message/recipient/:recipient_id`, diff --git a/yarn.lock b/yarn.lock index 357f2b3..349810e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5022,10 +5022,10 @@ lcid@^1.0.0: 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"