Skip to content

Commit

Permalink
Merge branch 'main' into issue-template-checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessOne1917 authored Jun 15, 2023
2 parents f3f634e + 148c795 commit 46a9cde
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
font-size: 1.2rem;
}

.md-div pre {
white-space: pre;
overflow-x: auto;
}

.md-div table {
border-collapse: collapse;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/home/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class Login extends Component<any, State> {
}

handleLoginUsernameChange(i: Login, event: any) {
i.state.form.username_or_email = event.target.value;
i.state.form.username_or_email = event.target.value.trim();
i.setState(i.state);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/home/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class Setup extends Component<any, State> {
}

handleRegisterUsernameChange(i: Setup, event: any) {
i.state.form.username = event.target.value;
i.state.form.username = event.target.value.trim();
i.setState(i.state);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/home/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export class Signup extends Component<any, State> {
}

handleRegisterUsernameChange(i: Signup, event: any) {
i.state.form.username = event.target.value;
i.state.form.username = event.target.value.trim();
i.setState(i.state);
}

Expand Down
45 changes: 41 additions & 4 deletions src/shared/components/post/post-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
isImage,
myAuth,
myAuthRequired,
pictrsDeleteToast,
relTags,
setupTippy,
toast,
Expand Down Expand Up @@ -73,6 +72,7 @@ interface PostFormState {
suggestedPostsRes: RequestState<SearchResponse>;
metadataRes: RequestState<GetSiteMetadataResponse>;
imageLoading: boolean;
imageDeleteUrl: string;
communitySearchLoading: boolean;
communitySearchOptions: Choice[];
previewMode: boolean;
Expand All @@ -86,6 +86,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
form: {},
loading: false,
imageLoading: false,
imageDeleteUrl: "",
communitySearchLoading: false,
previewMode: false,
communitySearchOptions: [],
Expand Down Expand Up @@ -269,6 +270,17 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
{url && isImage(url) && (
<img src={url} className="img-fluid" alt="" />
)}
{this.state.imageDeleteUrl && (
<button
className="btn btn-danger btn-sm mt-2"
onClick={linkEvent(this, this.handleImageDelete)}
aria-label={i18n.t("delete")}
data-tippy-content={i18n.t("delete")}
>
<Icon icon="x" classes="icon-inline mr-1" />
{capitalizeFirstLetter(i18n.t("delete"))}
</button>
)}
{this.props.crossPosts && this.props.crossPosts.length > 0 && (
<>
<div className="my-1 text-muted small font-weight-bold">
Expand Down Expand Up @@ -553,7 +565,15 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
}

handlePostUrlChange(i: PostForm, event: any) {
i.setState(s => ((s.form.url = event.target.value), s));
const url = event.target.value;

i.setState({
form: {
url,
},
imageDeleteUrl: "",
});

i.fetchPageTitle();
}

Expand Down Expand Up @@ -644,18 +664,35 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
if (res.state === "success") {
if (res.data.msg === "ok") {
i.state.form.url = res.data.url;
pictrsDeleteToast(file.name, res.data.delete_url as string);
i.setState({ imageLoading: false });
i.setState({
imageLoading: false,
imageDeleteUrl: res.data.delete_url as string,
});
} else {
toast(JSON.stringify(res), "danger");
}
} else if (res.state === "failed") {
console.error(res.msg);
toast(res.msg, "danger");
i.setState({ imageLoading: false });
}
});
}

handleImageDelete(i: PostForm) {
const { imageDeleteUrl } = i.state;

fetch(imageDeleteUrl);

i.setState({
imageDeleteUrl: "",
imageLoading: false,
form: {
url: "",
},
});
}

handleCommunitySearch = debounce(async (text: string) => {
const { selectedCommunityChoice } = this.props;
this.setState({ communitySearchLoading: true });
Expand Down
2 changes: 2 additions & 0 deletions src/shared/components/post/post-listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
search: "",
}}
title={i18n.t("cross_post")}
data-tippy-content={i18n.t("cross_post")}
aria-label={i18n.t("cross_post")}
>
<Icon icon="copy" inline />
</Link>
Expand Down

0 comments on commit 46a9cde

Please sign in to comment.