]> Untitled Git - lemmy-ui.git/commitdiff
Updating v2 API based on nutomics recommends.
authorDessalines <tyhou13@gmx.com>
Mon, 18 Jan 2021 22:42:41 +0000 (17:42 -0500)
committerDessalines <tyhou13@gmx.com>
Mon, 18 Jan 2021 22:42:41 +0000 (17:42 -0500)
16 files changed:
package.json
src/shared/components/comment-form.tsx
src/shared/components/comment-node.tsx
src/shared/components/community-form.tsx
src/shared/components/login.tsx
src/shared/components/post-form.tsx
src/shared/components/post-listing.tsx
src/shared/components/private-message-form.tsx
src/shared/components/private-message.tsx
src/shared/components/setup.tsx
src/shared/components/sidebar.tsx
src/shared/components/theme.tsx
src/shared/components/user.tsx
src/shared/services/UserService.ts
src/shared/utils.ts
yarn.lock

index 188e9ddcfa486486da7254bc1dba8c9ba2258ede..68afbc419610265ff3d7df635f9b7869f5262832 100644 (file)
@@ -67,7 +67,7 @@
     "eslint": "^7.16.0",
     "eslint-plugin-jane": "^9.0.6",
     "husky": "^4.3.6",
-    "lemmy-js-client": "1.0.17-beta6",
+    "lemmy-js-client": "0.9.0-rc.12",
     "lint-staged": "^10.5.3",
     "mini-css-extract-plugin": "^1.3.3",
     "node-fetch": "^2.6.1",
index 3e81d77525a66c023ce1752140cd26638b03e6d5..23febc7b6b23960fec11974630a3e2cbd276eafd 100644 (file)
@@ -109,7 +109,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
       let form: EditComment = {
         content,
         form_id: this.state.formId,
-        edit_id: node.comment_view.comment.id,
+        comment_id: node.comment_view.comment.id,
         auth: authField(),
       };
       WebSocketService.Instance.send(wsClient.editComment(form));
index b9de8559a750412c8a993b223467dee3af8585e9..dd6041119c68c2b0be9c358344ecefefc338f663 100644 (file)
@@ -854,7 +854,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
   handleDeleteClick(i: CommentNode) {
     let comment = i.props.node.comment_view.comment;
     let deleteForm: DeleteComment = {
-      edit_id: comment.id,
+      comment_id: comment.id,
       deleted: !comment.deleted,
       auth: authField(),
     };
@@ -956,7 +956,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
   handleModRemoveSubmit(i: CommentNode) {
     let comment = i.props.node.comment_view.comment;
     let form: RemoveComment = {
-      edit_id: comment.id,
+      comment_id: comment.id,
       removed: !comment.removed,
       reason: i.state.removeReason,
       auth: authField(),
index 18406fc7dc98b00120fc82cbec4daf55488f1dbd..df4b1713c5c6c564f56046d81d007d44d7936e07 100644 (file)
@@ -283,7 +283,7 @@ export class CommunityForm extends Component<
     if (i.props.community_view) {
       let form: EditCommunity = {
         ...i.state.communityForm,
-        edit_id: i.props.community_view.community.id,
+        community_id: i.props.community_view.community.id,
       };
       WebSocketService.Instance.send(wsClient.editCommunity(form));
     } else {
index c650c38e15070b9b4be482a34e2b05bcaddb1c14..ef8a5f7a62046d8b2ca6c1931383b8de3316ff1e 100644 (file)
@@ -48,7 +48,6 @@ export class Login extends Component<any, State> {
       username: undefined,
       password: undefined,
       password_verify: undefined,
-      admin: false,
       show_nsfw: false,
       captcha_uuid: undefined,
       captcha_answer: undefined,
index 3a59f457494e93493b56bbfd1804ad9ed8809dd6..08a5014bf950273f126d08c28fece82776fd04d2 100644 (file)
@@ -377,7 +377,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
     if (i.props.post_view) {
       let form: EditPost = {
         ...i.state.postForm,
-        edit_id: i.props.post_view.post.id,
+        post_id: i.props.post_view.post.id,
       };
       WebSocketService.Instance.send(wsClient.editPost(form));
     } else {
index de20c27cff72ac4ffcb5df3b4c3f690898b6c7b3..8798d0db50cdbdc9bf0ca905e48ef56c34b939c5 100644 (file)
@@ -1237,7 +1237,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
 
   handleDeleteClick(i: PostListing) {
     let deleteForm: DeletePost = {
-      edit_id: i.props.post_view.post.id,
+      post_id: i.props.post_view.post.id,
       deleted: !i.props.post_view.post.deleted,
       auth: authField(),
     };
@@ -1287,7 +1287,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
   handleModRemoveSubmit(i: PostListing) {
     event.preventDefault();
     let form: RemovePost = {
-      edit_id: i.props.post_view.post.id,
+      post_id: i.props.post_view.post.id,
       removed: !i.props.post_view.post.removed,
       reason: i.state.removeReason,
       auth: authField(),
@@ -1300,7 +1300,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
 
   handleModLock(i: PostListing) {
     let form: LockPost = {
-      edit_id: i.props.post_view.post.id,
+      post_id: i.props.post_view.post.id,
       locked: !i.props.post_view.post.locked,
       auth: authField(),
     };
@@ -1309,7 +1309,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
 
   handleModSticky(i: PostListing) {
     let form: StickyPost = {
-      edit_id: i.props.post_view.post.id,
+      post_id: i.props.post_view.post.id,
       stickied: !i.props.post_view.post.stickied,
       auth: authField(),
     };
index 9c518aa07d588096d99325ca584dc7b416589e34..568886908cebf1a3f2c5ff62681a7be8c015d177 100644 (file)
@@ -191,7 +191,7 @@ export class PrivateMessageForm extends Component<
     event.preventDefault();
     if (i.props.privateMessage) {
       let form: EditPrivateMessage = {
-        edit_id: i.props.privateMessage.private_message.id,
+        private_message_id: i.props.privateMessage.private_message.id,
         content: i.state.privateMessageForm.content,
         auth: authField(),
       };
index 9e2fd76ccef384146b4d4b6a5f530afbb73c60f4..0121ea80f2944723c3c938e8f620cb375ce005dc 100644 (file)
@@ -229,7 +229,7 @@ export class PrivateMessage extends Component<
 
   handleDeleteClick(i: PrivateMessage) {
     let form: DeletePrivateMessage = {
-      edit_id: i.props.private_message_view.private_message.id,
+      private_message_id: i.props.private_message_view.private_message.id,
       deleted: !i.props.private_message_view.private_message.deleted,
       auth: authField(),
     };
@@ -244,7 +244,7 @@ export class PrivateMessage extends Component<
 
   handleMarkRead(i: PrivateMessage) {
     let form: MarkPrivateMessageAsRead = {
-      edit_id: i.props.private_message_view.private_message.id,
+      private_message_id: i.props.private_message_view.private_message.id,
       read: !i.props.private_message_view.private_message.read,
       auth: authField(),
     };
index bb30bc2c32ac5511eaffd2cda0915697096ee5ac..1abd1c41e0cdf0ba24915c77beb583470a326ffb 100644 (file)
@@ -22,7 +22,6 @@ export class Setup extends Component<any, State> {
       username: undefined,
       password: undefined,
       password_verify: undefined,
-      admin: true,
       show_nsfw: true,
       // The first admin signup doesn't need a captcha
       captcha_uuid: '',
index d44eb14ab8b81a6524ec6db3dfec6242a8129454..76e141fb602ff9aaa36249627a73baffccd5ef00 100644 (file)
@@ -392,7 +392,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
   handleDeleteClick(i: Sidebar, event: any) {
     event.preventDefault();
     let deleteForm: DeleteCommunity = {
-      edit_id: i.props.community_view.community.id,
+      community_id: i.props.community_view.community.id,
       deleted: !i.props.community_view.community.deleted,
       auth: authField(),
     };
@@ -482,7 +482,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
   handleModRemoveSubmit(i: Sidebar, event: any) {
     event.preventDefault();
     let removeForm: RemoveCommunity = {
-      edit_id: i.props.community_view.community.id,
+      community_id: i.props.community_view.community.id,
       removed: !i.props.community_view.community.removed,
       reason: i.state.removeReason,
       expires: getUnixTime(i.state.removeExpires),
index 8da4ee1c27b960975886908106e33b38fcc64cb4..d13bbaca90955180372694e074255772c1bd8daa 100644 (file)
@@ -1,9 +1,9 @@
-import { User_ } from 'lemmy-js-client';
+import { UserSafeSettings } from 'lemmy-js-client';
 import { Helmet } from 'inferno-helmet';
 import { Component } from 'inferno';
 
 interface Props {
-  user: User_ | undefined;
+  user: UserSafeSettings | undefined;
 }
 
 export class Theme extends Component<Props> {
index f541c2f75d770cf1d37ddc1b71f483ece0efe924..555951e3da1e2757f76d953d0ac695983e11b22a 100644 (file)
@@ -150,8 +150,6 @@ export class User extends Component<any, UserState> {
     // Only fetch the data if coming from another route
     if (this.isoData.path == this.context.router.route.match.url) {
       this.state.userRes = this.isoData.routeData[0];
-      this.state.userRes.user_view =
-        this.state.userRes.user_view || this.state.userRes.user_view_dangerous;
       this.setUserInfo();
       this.state.loading = false;
     } else {
@@ -1106,8 +1104,6 @@ export class User extends Component<any, UserState> {
       // TODO this might need to get abstracted
       let data = wsJsonToRes<GetUserDetailsResponse>(msg).data;
       this.state.userRes = data;
-      this.state.userRes.user_view =
-        this.state.userRes.user_view || this.state.userRes.user_view_dangerous;
       this.setUserInfo();
       this.state.loading = false;
       this.setState(this.state);
index cdcd63f3b5890094628e0a6c9132404c873406a6..87eca1a201adf6efb68e32106882c5b4fd2a6184 100644 (file)
@@ -1,6 +1,6 @@
 // import Cookies from 'js-cookie';
 import IsomorphicCookie from 'isomorphic-cookie';
-import { User_, LoginResponse } from 'lemmy-js-client';
+import { UserSafeSettings, LoginResponse } from 'lemmy-js-client';
 import jwt_decode from 'jwt-decode';
 import { Subject, BehaviorSubject } from 'rxjs';
 
@@ -11,7 +11,7 @@ interface Claims {
 
 export class UserService {
   private static _instance: UserService;
-  public user: User_;
+  public user: UserSafeSettings;
   public claims: Claims;
   public jwtSub: Subject<string> = new Subject<string>();
   public unreadCountSub: BehaviorSubject<number> = new BehaviorSubject<number>(
index 504c3375d47cf995485eee2629bf90f3089ac0ac..b04fd0573b629b96641e304bfc9e9cfe931e285d 100644 (file)
@@ -31,7 +31,7 @@ import 'moment/locale/da';
 import {
   UserOperation,
   CommentView,
-  User_,
+  UserSafeSettings,
   SortType,
   ListingType,
   SearchType,
@@ -239,7 +239,7 @@ export function getUnixTime(text: string): number {
 }
 
 export function canMod(
-  user: User_,
+  user: UserSafeSettings,
   modIds: number[],
   creator_id: number,
   onSelf: boolean = false
index 50206a37334fc6f428ad8fb380e0f689ab2ae1e5..3cac95a2f7609dd189d24e3723d6ddf9b74d4f06 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -5555,10 +5555,10 @@ lcid@^1.0.0:
   dependencies:
     invert-kv "^1.0.0"
 
-lemmy-js-client@1.0.17-beta6:
-  version "1.0.17-beta6"
-  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.17-beta6.tgz#afe1e1da13172a161c4d976b1ee58fe81eb22829"
-  integrity sha512-+oX7J7wht8nH4a5NQngK1GNner3TDv6ZOhQQVI5KcK7vynVVIcgveC5KBJArHBAl5acXpLs3Khmx0ZEb+sErJA==
+lemmy-js-client@0.9.0-rc.12:
+  version "0.9.0-rc.12"
+  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.9.0-rc.12.tgz#991d31c4ef89b9bd4088a17c60b6cbaac997df41"
+  integrity sha512-SeCw9wjU89Zm4YWhr+neHC2XvqoqzJg2e42sFEgcDmnQxpPt2sND9Udu+tjGXatbz0tCu6ybGmpR5M0QT4xx9Q==
 
 leven@^3.1.0:
   version "3.1.0"