]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/components/post.tsx
Remove categories
[lemmy-ui.git] / src / shared / components / post.tsx
index 519c5fa27b334c6cdc9c3cea426025a0cf048799..b1bd9aaa52608b709621b5859f63361ae3db8d2d 100644 (file)
@@ -1,7 +1,7 @@
-import { Component, linkEvent } from 'inferno';
-import { HtmlTags } from './html-tags';
-import { Spinner } from './icon';
-import { Subscription } from 'rxjs';
+import { Component, linkEvent } from "inferno";
+import { HtmlTags } from "./html-tags";
+import { Spinner } from "./icon";
+import { Subscription } from "rxjs";
 import {
   UserOperation,
   PostView,
@@ -21,16 +21,14 @@ import {
   SearchResponse,
   GetSiteResponse,
   GetCommunityResponse,
-  ListCategoriesResponse,
-  Category,
-} from 'lemmy-js-client';
+} from "lemmy-js-client";
 import {
   CommentSortType,
   CommentViewType,
   InitialFetchRequest,
   CommentNode as CommentNodeI,
-} from '../interfaces';
-import { WebSocketService, UserService } from '../services';
+} from "../interfaces";
+import { WebSocketService, UserService } from "../services";
 import {
   wsJsonToRes,
   toast,
@@ -55,13 +53,13 @@ import {
   restoreScrollPosition,
   buildCommentsTree,
   insertCommentIntoTree,
-} from '../utils';
-import { PostListing } from './post-listing';
-import { Sidebar } from './sidebar';
-import { CommentForm } from './comment-form';
-import { CommentNodes } from './comment-nodes';
-import autosize from 'autosize';
-import { i18n } from '../i18next';
+} from "../utils";
+import { PostListing } from "./post-listing";
+import { Sidebar } from "./sidebar";
+import { CommentForm } from "./comment-form";
+import { CommentNodes } from "./comment-nodes";
+import autosize from "autosize";
+import { i18n } from "../i18next";
 
 interface PostState {
   postRes: GetPostResponse;
@@ -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());
     }
   }
 
@@ -147,7 +141,7 @@ export class Post extends Component<any, PostState> {
   }
 
   static fetchInitialData(req: InitialFetchRequest): Promise<any>[] {
-    let pathSplit = req.path.split('/');
+    let pathSplit = req.path.split("/");
     let promises: Promise<any>[] = [];
 
     let id = Number(pathSplit[2]);
@@ -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;
   }
@@ -173,10 +166,10 @@ export class Post extends Component<any, PostState> {
     WebSocketService.Instance.send(
       wsClient.postJoin({ post_id: this.state.postId })
     );
-    autosize(document.querySelectorAll('textarea'));
+    autosize(document.querySelectorAll("textarea"));
   }
 
-  componentDidUpdate(_lastProps: any, lastState: PostState, _snapshot: any) {
+  componentDidUpdate(_lastProps: any, lastState: PostState) {
     if (
       this.state.commentId &&
       !this.state.scrolled &&
@@ -201,7 +194,7 @@ export class Post extends Component<any, PostState> {
   scrollCommentIntoView() {
     var elmnt = document.getElementById(`comment-${this.state.commentId}`);
     elmnt.scrollIntoView();
-    elmnt.classList.add('mark');
+    elmnt.classList.add("mark");
     this.state.scrolled = true;
     this.markScrolledAsRead(this.state.commentId);
   }
@@ -304,10 +297,10 @@ export class Post extends Component<any, PostState> {
         <div class="btn-group btn-group-toggle flex-wrap mr-3 mb-2">
           <label
             className={`btn btn-outline-secondary pointer ${
-              this.state.commentSort === CommentSortType.Hot && 'active'
+              this.state.commentSort === CommentSortType.Hot && "active"
             }`}
           >
-            {i18n.t('hot')}
+            {i18n.t("hot")}
             <input
               type="radio"
               value={CommentSortType.Hot}
@@ -317,10 +310,10 @@ export class Post extends Component<any, PostState> {
           </label>
           <label
             className={`btn btn-outline-secondary pointer ${
-              this.state.commentSort === CommentSortType.Top && 'active'
+              this.state.commentSort === CommentSortType.Top && "active"
             }`}
           >
-            {i18n.t('top')}
+            {i18n.t("top")}
             <input
               type="radio"
               value={CommentSortType.Top}
@@ -330,10 +323,10 @@ export class Post extends Component<any, PostState> {
           </label>
           <label
             className={`btn btn-outline-secondary pointer ${
-              this.state.commentSort === CommentSortType.New && 'active'
+              this.state.commentSort === CommentSortType.New && "active"
             }`}
           >
-            {i18n.t('new')}
+            {i18n.t("new")}
             <input
               type="radio"
               value={CommentSortType.New}
@@ -343,10 +336,10 @@ export class Post extends Component<any, PostState> {
           </label>
           <label
             className={`btn btn-outline-secondary pointer ${
-              this.state.commentSort === CommentSortType.Old && 'active'
+              this.state.commentSort === CommentSortType.Old && "active"
             }`}
           >
-            {i18n.t('old')}
+            {i18n.t("old")}
             <input
               type="radio"
               value={CommentSortType.Old}
@@ -358,10 +351,10 @@ export class Post extends Component<any, PostState> {
         <div class="btn-group btn-group-toggle flex-wrap mb-2">
           <label
             className={`btn btn-outline-secondary pointer ${
-              this.state.commentViewType === CommentViewType.Chat && 'active'
+              this.state.commentViewType === CommentViewType.Chat && "active"
             }`}
           >
-            {i18n.t('chat')}
+            {i18n.t("chat")}
             <input
               type="radio"
               value={CommentViewType.Chat}
@@ -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>
     );
@@ -447,7 +439,7 @@ export class Post extends Component<any, PostState> {
     let op = wsUserOp(msg);
     console.log(msg);
     if (msg.error) {
-      toast(i18n.t(msg.error), 'danger');
+      toast(i18n.t(msg.error), "danger");
       return;
     } else if (msg.reconnect) {
       let postId = Number(this.props.match.params.id);
@@ -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);
     }
   }
 }