]> Untitled Git - lemmy-ui.git/commitdiff
A few fixes.
authorDessalines <tyhou13@gmx.com>
Sat, 26 Dec 2020 03:28:05 +0000 (22:28 -0500)
committerDessalines <tyhou13@gmx.com>
Sat, 26 Dec 2020 03:28:05 +0000 (22:28 -0500)
package.json
src/shared/components/community-form.tsx
src/shared/components/inbox.tsx
src/shared/components/post-form.tsx
src/shared/components/post-listing.tsx
src/shared/components/user-details.tsx
src/shared/components/user.tsx
src/shared/utils.ts
yarn.lock

index ab8b95821c2221bde2f47858cd00cc53cf8adda1..9296b26e8a8beec8f94b8fd59dd6b5ec75957e26 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-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",
index b40899af45fe74fe6747ecfa1d4bff810c902335..18406fc7dc98b00120fc82cbec4daf55488f1dbd 100644 (file)
@@ -54,7 +54,7 @@ export class CommunityForm extends Component<
       nsfw: false,
       icon: null,
       banner: null,
-      auth: authField(),
+      auth: authField(false),
     },
     loading: false,
   };
index 0a4c11ca6d41a54f450c1339db2e5580a4612e54..6c6f5d903d39235f042024f4e467326b22fba45a 100644 (file)
@@ -108,10 +108,9 @@ export class Inbox extends Component<any, InboxState> {
 
     // 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();
index f4ff5ea66ed8a5e6d0c9d50a447d2c6bb79b6ed0..3a59f457494e93493b56bbfd1804ad9ed8809dd6 100644 (file)
@@ -78,7 +78,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
       community_id: null,
       name: null,
       nsfw: false,
-      auth: authField(),
+      auth: authField(false),
     },
     loading: false,
     imageLoading: false,
index 7bf2174f3f044923f78ac6fb25bd6b9dda9a507f..de20c27cff72ac4ffcb5df3b4c3f690898b6c7b3 100644 (file)
@@ -601,14 +601,16 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
   }
 
   duplicatesLine() {
+    let dupes = this.props.duplicates;
     return (
-      this.props.duplicates && (
+      dupes &&
+      dupes.length > 0 && (
         <ul class="list-inline mb-1 small text-muted">
           <>
             <li className="list-inline-item mr-2">
               {i18n.t('cross_posted_to')}
             </li>
-            {this.props.duplicates.map(pv => (
+            {dupes.map(pv => (
               <li className="list-inline-item mr-2">
                 <Link to={`/post/${pv.post.id}`}>
                   {pv.community.local
index f128158896a7fdd045065222ea0a3e24425f1dab..59e844daccddecfa684958d1a1963bc087ae1f62 100644 (file)
@@ -123,7 +123,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
     }));
     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,
index 9cf7d666df42377ffc03b7b51a8be2d4cfe8fbc0..f541c2f75d770cf1d37ddc1b71f483ece0efe924 100644 (file)
@@ -110,14 +110,14 @@ export class User extends Component<any, UserState> {
       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<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 {
@@ -398,7 +400,7 @@ export class User extends Component<any, UserState> {
   }
 
   userInfo() {
-    let uv = this.state.userRes.user_view;
+    let uv = this.state.userRes?.user_view;
 
     return (
       <div>
@@ -937,12 +939,16 @@ export class User extends Component<any, UserState> {
   }
 
   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<any, UserState> {
   }
 
   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<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 55856815dea2d1f2f26ba5ad4a37fadb635d8468..433b674baeefaa13cc45b9ae4a106513edfabb1f 100644 (file)
@@ -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];
 }
index f7507c5f8f7e6ecbc671c0cb66018518e17a03dd..50206a37334fc6f428ad8fb380e0f689ab2ae1e5 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-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"