]> Untitled Git - lemmy-ui.git/commitdiff
Remove categories
authorFelix Ableitner <me@nutomic.com>
Wed, 3 Mar 2021 16:59:57 +0000 (17:59 +0100)
committerFelix Ableitner <me@nutomic.com>
Wed, 3 Mar 2021 16:59:57 +0000 (17:59 +0100)
package.json
src/shared/components/communities.tsx
src/shared/components/community-form.tsx
src/shared/components/community.tsx
src/shared/components/create-community.tsx
src/shared/components/post.tsx
src/shared/components/sidebar.tsx
src/shared/routes.ts
yarn.lock

index e427117a914d07a11db737dd07ee60697c3d0edc..96fd0c2696a6fc02b3c596722d95287b102809e0 100644 (file)
@@ -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",
index def03dfc713337e2821d8e64ee1e672493e8cd4a..74a1ac32a27e3495cecfe5a225ca4e54e7b71d65 100644 (file)
@@ -124,7 +124,6 @@ export class Communities extends Component<any, CommunitiesState> {
                 <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")}
@@ -144,7 +143,6 @@ export class Communities extends Component<any, CommunitiesState> {
                       <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">
index 5b8034c5598f2522ae973edc3bf7a8256e40521a..97d335e2b7c7fd79c43c3e297e062d7fe86b0d2a 100644 (file)
@@ -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<
               />
             </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">
@@ -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);
index ef5c7833d85a126f297c7e5d10d2c5fb1495f312..9f492cd35c92a7ce9b190806be0a1874881ce664 100644 (file)
@@ -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<any, State> {
     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<any, State> {
       } 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<any, State> {
       promises.push(req.client.getComments(getCommentsForm));
     }
 
-    promises.push(req.client.listCategories());
-
     return promises;
   }
 
@@ -268,7 +260,6 @@ export class Community extends Component<any, State> {
                 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>
@@ -541,10 +532,6 @@ export class Community extends Component<any, State> {
       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);
     }
   }
 }
index da4499789005eb3570fbd151f8205e304ffb01d3..e1a9cf8f4d01ec0a3b692c77161da31968cd3838 100644 (file)
@@ -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<any, CreateCommunityState> {
   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<any, CreateCommunityState> {
 
     // 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<any, CreateCommunityState> {
             <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}
               />
@@ -100,20 +87,10 @@ export class CreateCommunity extends Component<any, CreateCommunityState> {
     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);
     }
   }
 }
index 610249915d5ed5d70c9eb40b98ee7fa2dafed1bb..b1bd9aaa52608b709621b5859f63361ae3db8d2d 100644 (file)
@@ -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<any, PostState> {
@@ -91,7 +88,6 @@ export class Post extends Component<any, PostState> {
     loading: true,
     crossPosts: [],
     siteRes: this.isoData.site_res,
-    categories: [],
   };
 
   constructor(props: any, context: any) {
@@ -109,7 +105,6 @@ export class Post extends Component<any, PostState> {
         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<any, PostState> {
       }
     } else {
       this.fetchPost();
-      WebSocketService.Instance.send(wsClient.listCategories());
     }
   }
 
@@ -158,7 +152,6 @@ export class Post extends Component<any, PostState> {
     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<any, PostState> {
           online={this.state.postRes.online}
           enableNsfw={this.state.siteRes.site_view.site.enable_nsfw}
           showIcon
-          categories={this.state.categories}
         />
       </div>
     );
@@ -570,10 +562,6 @@ export class Post extends Component<any, PostState> {
       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);
     }
   }
 }
index 436d6cfab2933145128bc42f47e78c6f6f752870..47de96da8f903e5461c5d0e092d89c0b4bfa57e5 100644 (file)
@@ -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<SidebarProps, SidebarState> {
           this.sidebar()
         ) : (
           <CommunityForm
-            categories={this.props.categories}
             community_view={this.props.community_view}
             onEdit={this.handleEditCommunity}
             onCancel={this.handleEditCancel}
@@ -209,11 +206,6 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
             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"
index ce2eafed67f44b6c157158ca642ea2c60a7a4080..e26416ede1b13b70b195a797d2710d8548d95f71 100644 (file)
@@ -45,7 +45,6 @@ export const routes: IRoutePropsWithFetch[] = [
   {
     path: `/create_community`,
     component: CreateCommunity,
-    fetchInitialData: req => CreateCommunity.fetchInitialData(req),
   },
   {
     path: `/create_private_message/recipient/:recipient_id`,
index 357f2b341d48b2da5ec39db179143b44142b36b2..349810ee546305728b891a27b33f59a1244185c8 100644 (file)
--- 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"