A few fixes.

This commit is contained in:
Dessalines 2020-12-25 22:28:05 -05:00
parent 368d4199a5
commit 325285951c
9 changed files with 36 additions and 20 deletions

View file

@ -67,7 +67,7 @@
"eslint": "^7.16.0", "eslint": "^7.16.0",
"eslint-plugin-jane": "^9.0.6", "eslint-plugin-jane": "^9.0.6",
"husky": "^4.3.6", "husky": "^4.3.6",
"lemmy-js-client": "1.0.17-beta5", "lemmy-js-client": "1.0.17-beta6",
"lint-staged": "^10.5.3", "lint-staged": "^10.5.3",
"mini-css-extract-plugin": "^1.3.3", "mini-css-extract-plugin": "^1.3.3",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",

View file

@ -54,7 +54,7 @@ export class CommunityForm extends Component<
nsfw: false, nsfw: false,
icon: null, icon: null,
banner: null, banner: null,
auth: authField(), auth: authField(false),
}, },
loading: false, loading: false,
}; };

View file

@ -108,10 +108,9 @@ export class Inbox extends Component<any, InboxState> {
// Only fetch the data if coming from another route // Only fetch the data if coming from another route
if (this.isoData.path == this.context.router.route.match.url) { if (this.isoData.path == this.context.router.route.match.url) {
this.state.replies = this.isoData.routeData[0].replies; this.state.replies = this.isoData.routeData[0].replies || [];
this.state.mentions = this.isoData.routeData[1].mentions; this.state.mentions = this.isoData.routeData[1].mentions || [];
this.state.messages = this.isoData.routeData[2].messages; this.state.messages = this.isoData.routeData[2].messages || [];
this.sendUnreadCount();
this.state.loading = false; this.state.loading = false;
} else { } else {
this.refetch(); this.refetch();

View file

@ -78,7 +78,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
community_id: null, community_id: null,
name: null, name: null,
nsfw: false, nsfw: false,
auth: authField(), auth: authField(false),
}, },
loading: false, loading: false,
imageLoading: false, imageLoading: false,

View file

@ -601,14 +601,16 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
} }
duplicatesLine() { duplicatesLine() {
let dupes = this.props.duplicates;
return ( return (
this.props.duplicates && ( dupes &&
dupes.length > 0 && (
<ul class="list-inline mb-1 small text-muted"> <ul class="list-inline mb-1 small text-muted">
<> <>
<li className="list-inline-item mr-2"> <li className="list-inline-item mr-2">
{i18n.t('cross_posted_to')} {i18n.t('cross_posted_to')}
</li> </li>
{this.props.duplicates.map(pv => ( {dupes.map(pv => (
<li className="list-inline-item mr-2"> <li className="list-inline-item mr-2">
<Link to={`/post/${pv.post.id}`}> <Link to={`/post/${pv.post.id}`}>
{pv.community.local {pv.community.local

View file

@ -123,7 +123,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
})); }));
let posts: ItemType[] = this.props.userRes.posts.map(r => ({ let posts: ItemType[] = this.props.userRes.posts.map(r => ({
id: id++, id: id++,
type_: ItemEnum.Comment, type_: ItemEnum.Post,
view: r, view: r,
published: r.post.published, published: r.post.published,
score: r.counts.score, score: r.counts.score,

View file

@ -110,14 +110,14 @@ export class User extends Component<any, UserState> {
send_notifications_to_email: null, send_notifications_to_email: null,
bio: null, bio: null,
preferred_username: null, preferred_username: null,
auth: authField(), auth: authField(false),
}, },
userSettingsLoading: null, userSettingsLoading: null,
deleteAccountLoading: null, deleteAccountLoading: null,
deleteAccountShowConfirm: false, deleteAccountShowConfirm: false,
deleteAccountForm: { deleteAccountForm: {
password: null, password: null,
auth: authField(), auth: authField(false),
}, },
siteRes: this.isoData.site_res, 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 // Only fetch the data if coming from another route
if (this.isoData.path == this.context.router.route.match.url) { if (this.isoData.path == this.context.router.route.match.url) {
this.state.userRes = this.isoData.routeData[0]; 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.setUserInfo();
this.state.loading = false; this.state.loading = false;
} else { } else {
@ -398,7 +400,7 @@ export class User extends Component<any, UserState> {
} }
userInfo() { userInfo() {
let uv = this.state.userRes.user_view; let uv = this.state.userRes?.user_view;
return ( return (
<div> <div>
@ -937,12 +939,16 @@ export class User extends Component<any, UserState> {
} }
handleUserSettingsSortTypeChange(val: SortType) { 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); this.setState(this.state);
} }
handleUserSettingsListingTypeChange(val: ListingType) { 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); this.setState(this.state);
} }
@ -1081,7 +1087,6 @@ export class User extends Component<any, UserState> {
} }
parseMessage(msg: any) { parseMessage(msg: any) {
console.log(msg);
let op = wsUserOp(msg); let op = wsUserOp(msg);
if (msg.error) { if (msg.error) {
toast(i18n.t(msg.error), 'danger'); toast(i18n.t(msg.error), 'danger');
@ -1101,6 +1106,8 @@ export class User extends Component<any, UserState> {
// TODO this might need to get abstracted // TODO this might need to get abstracted
let data = wsJsonToRes<GetUserDetailsResponse>(msg).data; let data = wsJsonToRes<GetUserDetailsResponse>(msg).data;
this.state.userRes = data; this.state.userRes = data;
this.state.userRes.user_view =
this.state.userRes.user_view || this.state.userRes.user_view_dangerous;
this.setUserInfo(); this.setUserInfo();
this.state.loading = false; this.state.loading = false;
this.setState(this.state); this.setState(this.state);

View file

@ -297,6 +297,14 @@ export function routeSortTypeToEnum(sort: string): SortType {
return SortType[sort]; 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 { export function routeListingTypeToEnum(type: string): ListingType {
return ListingType[type]; return ListingType[type];
} }

View file

@ -5555,10 +5555,10 @@ lcid@^1.0.0:
dependencies: dependencies:
invert-kv "^1.0.0" invert-kv "^1.0.0"
lemmy-js-client@1.0.17-beta5: lemmy-js-client@1.0.17-beta6:
version "1.0.17-beta5" version "1.0.17-beta6"
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.17-beta5.tgz#b8d128ef3a6a17bc3ac4eea8e30618b68ea4f2df" resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.17-beta6.tgz#afe1e1da13172a161c4d976b1ee58fe81eb22829"
integrity sha512-Z/8HV8tG9aB75GjDX1U2b3pFZnysGIymeVO+oepOkYfhHRB8SKmLS9ATuIw9OW1NjJduxbpGGgDH+bkf0Sx7dA== integrity sha512-+oX7J7wht8nH4a5NQngK1GNner3TDv6ZOhQQVI5KcK7vynVVIcgveC5KBJArHBAl5acXpLs3Khmx0ZEb+sErJA==
leven@^3.1.0: leven@^3.1.0:
version "3.1.0" version "3.1.0"