From: Dessalines Date: Sat, 26 Dec 2020 03:28:05 +0000 (-0500) Subject: A few fixes. X-Git-Url: http://these/git/%7B%60%24%7BrepoUrl%7D/blob/master/docs/%7BrepoUrl%7D?a=commitdiff_plain;h=325285951c676ae6b91cb452d876e819196f84b1;p=lemmy-ui.git A few fixes. --- diff --git a/package.json b/package.json index ab8b958..9296b26 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-beta5", + "lemmy-js-client": "1.0.17-beta6", "lint-staged": "^10.5.3", "mini-css-extract-plugin": "^1.3.3", "node-fetch": "^2.6.1", diff --git a/src/shared/components/community-form.tsx b/src/shared/components/community-form.tsx index b40899a..18406fc 100644 --- a/src/shared/components/community-form.tsx +++ b/src/shared/components/community-form.tsx @@ -54,7 +54,7 @@ export class CommunityForm extends Component< nsfw: false, icon: null, banner: null, - auth: authField(), + auth: authField(false), }, loading: false, }; diff --git a/src/shared/components/inbox.tsx b/src/shared/components/inbox.tsx index 0a4c11c..6c6f5d9 100644 --- a/src/shared/components/inbox.tsx +++ b/src/shared/components/inbox.tsx @@ -108,10 +108,9 @@ export class Inbox extends Component { // Only fetch the data if coming from another route if (this.isoData.path == this.context.router.route.match.url) { - this.state.replies = this.isoData.routeData[0].replies; - this.state.mentions = this.isoData.routeData[1].mentions; - this.state.messages = this.isoData.routeData[2].messages; - this.sendUnreadCount(); + this.state.replies = this.isoData.routeData[0].replies || []; + this.state.mentions = this.isoData.routeData[1].mentions || []; + this.state.messages = this.isoData.routeData[2].messages || []; this.state.loading = false; } else { this.refetch(); diff --git a/src/shared/components/post-form.tsx b/src/shared/components/post-form.tsx index f4ff5ea..3a59f45 100644 --- a/src/shared/components/post-form.tsx +++ b/src/shared/components/post-form.tsx @@ -78,7 +78,7 @@ export class PostForm extends Component { community_id: null, name: null, nsfw: false, - auth: authField(), + auth: authField(false), }, loading: false, imageLoading: false, diff --git a/src/shared/components/post-listing.tsx b/src/shared/components/post-listing.tsx index 7bf2174..de20c27 100644 --- a/src/shared/components/post-listing.tsx +++ b/src/shared/components/post-listing.tsx @@ -601,14 +601,16 @@ export class PostListing extends Component { } duplicatesLine() { + let dupes = this.props.duplicates; return ( - this.props.duplicates && ( + dupes && + dupes.length > 0 && (
    <>
  • {i18n.t('cross_posted_to')}
  • - {this.props.duplicates.map(pv => ( + {dupes.map(pv => (
  • {pv.community.local diff --git a/src/shared/components/user-details.tsx b/src/shared/components/user-details.tsx index f128158..59e844d 100644 --- a/src/shared/components/user-details.tsx +++ b/src/shared/components/user-details.tsx @@ -123,7 +123,7 @@ export class UserDetails extends Component { })); let posts: ItemType[] = this.props.userRes.posts.map(r => ({ id: id++, - type_: ItemEnum.Comment, + type_: ItemEnum.Post, view: r, published: r.post.published, score: r.counts.score, diff --git a/src/shared/components/user.tsx b/src/shared/components/user.tsx index 9cf7d66..f541c2f 100644 --- a/src/shared/components/user.tsx +++ b/src/shared/components/user.tsx @@ -110,14 +110,14 @@ export class User extends Component { send_notifications_to_email: null, bio: null, preferred_username: null, - auth: authField(), + auth: authField(false), }, userSettingsLoading: null, deleteAccountLoading: null, deleteAccountShowConfirm: false, deleteAccountForm: { password: null, - auth: authField(), + auth: authField(false), }, siteRes: this.isoData.site_res, }; @@ -150,6 +150,8 @@ 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 { @@ -398,7 +400,7 @@ export class User extends Component { } userInfo() { - let uv = this.state.userRes.user_view; + let uv = this.state.userRes?.user_view; return (
    @@ -937,12 +939,16 @@ export class User extends Component { } handleUserSettingsSortTypeChange(val: SortType) { - this.state.userSettingsForm.default_sort_type = val; + this.state.userSettingsForm.default_sort_type = Object.keys( + SortType + ).indexOf(val); this.setState(this.state); } handleUserSettingsListingTypeChange(val: ListingType) { - this.state.userSettingsForm.default_listing_type = val; + this.state.userSettingsForm.default_listing_type = Object.keys( + ListingType + ).indexOf(val); this.setState(this.state); } @@ -1081,7 +1087,6 @@ export class User extends Component { } parseMessage(msg: any) { - console.log(msg); let op = wsUserOp(msg); if (msg.error) { toast(i18n.t(msg.error), 'danger'); @@ -1101,6 +1106,8 @@ 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/utils.ts b/src/shared/utils.ts index 5585681..433b674 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -297,6 +297,14 @@ export function routeSortTypeToEnum(sort: string): SortType { return SortType[sort]; } +export function listingTypeFromNum(type_: number): ListingType { + return Object.values(ListingType)[type_]; +} + +export function sortTypeFromNum(type_: number): SortType { + return Object.values(SortType)[type_]; +} + export function routeListingTypeToEnum(type: string): ListingType { return ListingType[type]; } diff --git a/yarn.lock b/yarn.lock index f7507c5..50206a3 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-beta5: - version "1.0.17-beta5" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.17-beta5.tgz#b8d128ef3a6a17bc3ac4eea8e30618b68ea4f2df" - integrity sha512-Z/8HV8tG9aB75GjDX1U2b3pFZnysGIymeVO+oepOkYfhHRB8SKmLS9ATuIw9OW1NjJduxbpGGgDH+bkf0Sx7dA== +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== leven@^3.1.0: version "3.1.0"