From: Dessalines Date: Mon, 18 Jan 2021 22:42:41 +0000 (-0500) Subject: Updating v2 API based on nutomics recommends. X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/save/static/git-logo.png?a=commitdiff_plain;h=6a3329f9a2bf75c94bcd73d7845a62ffa4ca9650;p=lemmy-ui.git Updating v2 API based on nutomics recommends. --- diff --git a/package.json b/package.json index 188e9dd..68afbc4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/shared/components/comment-form.tsx b/src/shared/components/comment-form.tsx index 3e81d77..23febc7 100644 --- a/src/shared/components/comment-form.tsx +++ b/src/shared/components/comment-form.tsx @@ -109,7 +109,7 @@ export class CommentForm extends Component { 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)); diff --git a/src/shared/components/comment-node.tsx b/src/shared/components/comment-node.tsx index b9de855..dd60411 100644 --- a/src/shared/components/comment-node.tsx +++ b/src/shared/components/comment-node.tsx @@ -854,7 +854,7 @@ export class CommentNode extends Component { 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 { 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(), diff --git a/src/shared/components/community-form.tsx b/src/shared/components/community-form.tsx index 18406fc..df4b171 100644 --- a/src/shared/components/community-form.tsx +++ b/src/shared/components/community-form.tsx @@ -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 { diff --git a/src/shared/components/login.tsx b/src/shared/components/login.tsx index c650c38..ef8a5f7 100644 --- a/src/shared/components/login.tsx +++ b/src/shared/components/login.tsx @@ -48,7 +48,6 @@ export class Login extends Component { username: undefined, password: undefined, password_verify: undefined, - admin: false, show_nsfw: false, captcha_uuid: undefined, captcha_answer: undefined, diff --git a/src/shared/components/post-form.tsx b/src/shared/components/post-form.tsx index 3a59f45..08a5014 100644 --- a/src/shared/components/post-form.tsx +++ b/src/shared/components/post-form.tsx @@ -377,7 +377,7 @@ export class PostForm extends Component { 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 { diff --git a/src/shared/components/post-listing.tsx b/src/shared/components/post-listing.tsx index de20c27..8798d0d 100644 --- a/src/shared/components/post-listing.tsx +++ b/src/shared/components/post-listing.tsx @@ -1237,7 +1237,7 @@ export class PostListing extends Component { 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 { 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 { 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 { 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(), }; diff --git a/src/shared/components/private-message-form.tsx b/src/shared/components/private-message-form.tsx index 9c518aa..5688869 100644 --- a/src/shared/components/private-message-form.tsx +++ b/src/shared/components/private-message-form.tsx @@ -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(), }; diff --git a/src/shared/components/private-message.tsx b/src/shared/components/private-message.tsx index 9e2fd76..0121ea8 100644 --- a/src/shared/components/private-message.tsx +++ b/src/shared/components/private-message.tsx @@ -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(), }; diff --git a/src/shared/components/setup.tsx b/src/shared/components/setup.tsx index bb30bc2..1abd1c4 100644 --- a/src/shared/components/setup.tsx +++ b/src/shared/components/setup.tsx @@ -22,7 +22,6 @@ export class Setup extends Component { username: undefined, password: undefined, password_verify: undefined, - admin: true, show_nsfw: true, // The first admin signup doesn't need a captcha captcha_uuid: '', diff --git a/src/shared/components/sidebar.tsx b/src/shared/components/sidebar.tsx index d44eb14..76e141f 100644 --- a/src/shared/components/sidebar.tsx +++ b/src/shared/components/sidebar.tsx @@ -392,7 +392,7 @@ export class Sidebar extends Component { 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 { 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), diff --git a/src/shared/components/theme.tsx b/src/shared/components/theme.tsx index 8da4ee1..d13bbac 100644 --- a/src/shared/components/theme.tsx +++ b/src/shared/components/theme.tsx @@ -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 { diff --git a/src/shared/components/user.tsx b/src/shared/components/user.tsx index f541c2f..555951e 100644 --- a/src/shared/components/user.tsx +++ b/src/shared/components/user.tsx @@ -150,8 +150,6 @@ export class User extends Component { // 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 { // TODO this might need to get abstracted let data = wsJsonToRes(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); diff --git a/src/shared/services/UserService.ts b/src/shared/services/UserService.ts index cdcd63f..87eca1a 100644 --- a/src/shared/services/UserService.ts +++ b/src/shared/services/UserService.ts @@ -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 = new Subject(); public unreadCountSub: BehaviorSubject = new BehaviorSubject( diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 504c337..b04fd05 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -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 diff --git a/yarn.lock b/yarn.lock index 50206a3..3cac95a 100644 --- 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"