CommunityView,
CreatePost,
EditPost,
+ Language,
ListingType,
PostResponse,
PostView,
ghostArchiveUrl,
isBrowser,
isImage,
+ myFirstDiscussionLanguageId,
pictrsDeleteToast,
relTags,
setupTippy,
wsSubscribe,
} from "../../utils";
import { Icon, Spinner } from "../common/icon";
+import { LanguageSelect } from "../common/language-select";
import { MarkdownTextArea } from "../common/markdown-textarea";
import { PostListings } from "./post-listings";
interface PostFormProps {
post_view: Option<PostView>; // If a post is given, that means this is an edit
+ allLanguages: Language[];
+ siteLanguages: number[];
communities: Option<CommunityView[]>;
params: Option<PostFormParams>;
onCancel?(): any;
crossPosts: Option<PostView[]>;
loading: boolean;
imageLoading: boolean;
+ communitySearchLoading: boolean;
previewMode: boolean;
}
url: None,
body: None,
honeypot: None,
+ language_id: None,
auth: undefined,
}),
loading: false,
imageLoading: false,
+ communitySearchLoading: false,
previewMode: false,
suggestedTitle: None,
suggestedPosts: None,
this.fetchSimilarPosts = debounce(this.fetchSimilarPosts.bind(this));
this.fetchPageTitle = debounce(this.fetchPageTitle.bind(this));
this.handlePostBodyChange = this.handlePostBodyChange.bind(this);
+ this.handleLanguageChange = this.handleLanguageChange.bind(this);
this.state = this.emptyState;
url: pv.post.url,
nsfw: Some(pv.post.nsfw),
honeypot: None,
+ language_id: Some(pv.post.language_id),
auth: auth().unwrap(),
}),
};
}
render() {
+ let selectedLangs = this.state.postForm.language_id
+ .or(
+ myFirstDiscussionLanguageId(
+ this.props.allLanguages,
+ this.props.siteLanguages,
+ UserService.Instance.myUserInfo
+ )
+ )
+ .map(Array.of);
+
return (
<div>
<Prompt
posts={xPosts}
enableDownvotes={this.props.enableDownvotes}
enableNsfw={this.props.enableNsfw}
+ allLanguages={this.props.allLanguages}
+ siteLanguages={this.props.siteLanguages}
/>
</>
),
posts={sPosts}
enableDownvotes={this.props.enableDownvotes}
enableNsfw={this.props.enableNsfw}
+ allLanguages={this.props.allLanguages}
+ siteLanguages={this.props.siteLanguages}
/>
</>
),
<div className="col-sm-10">
<MarkdownTextArea
initialContent={this.state.postForm.body}
+ initialLanguageId={None}
onContentChange={this.handlePostBodyChange}
placeholder={None}
buttonTitle={None}
maxLength={None}
+ allLanguages={this.props.allLanguages}
+ siteLanguages={this.props.siteLanguages}
/>
</div>
</div>
className="col-sm-2 col-form-label"
htmlFor="post-community"
>
- {i18n.t("community")}
+ {this.state.communitySearchLoading ? (
+ <Spinner />
+ ) : (
+ i18n.t("community")
+ )}
</label>
<div className="col-sm-10">
<select
</div>
</div>
)}
+ <LanguageSelect
+ allLanguages={this.props.allLanguages}
+ siteLanguages={this.props.siteLanguages}
+ selectedLanguageIds={selectedLangs}
+ multiple={false}
+ onChange={this.handleLanguageChange}
+ />
<input
tabIndex={-1}
autoComplete="false"
body: pForm.body,
nsfw: pForm.nsfw,
post_id: pv.post.id,
+ language_id: Some(pv.post.language_id),
auth: auth().unwrap(),
});
WebSocketService.Instance.send(wsClient.editPost(form));
i.setState(s => ((s.postForm.nsfw = Some(event.target.checked)), s));
}
+ handleLanguageChange(val: number[]) {
+ this.setState(s => ((s.postForm.language_id = Some(val[0])), s));
+ }
+
handleHoneyPotChange(i: PostForm, event: any) {
i.setState(s => ((s.postForm.honeypot = Some(event.target.value)), s));
}
i.state.postForm.url = Some(url);
i.setState({ imageLoading: false });
pictrsDeleteToast(
- i18n.t("click_to_delete_picture"),
- i18n.t("picture_deleted"),
+ `${i18n.t("click_to_delete_picture")}: ${file.name}`,
+ `${i18n.t("picture_deleted")}: ${file.name}`,
+ `${i18n.t("failed_to_delete_picture")}: ${file.name}`,
deleteUrl
);
} else {
},
false
);
+ this.choices.passedElement.element.addEventListener("search", () => {
+ this.setState({ communitySearchLoading: true });
+ });
this.choices.passedElement.element.addEventListener(
"search",
debounce(async (e: any) => {
"label",
true
);
+ this.setState({ communitySearchLoading: false });
} catch (err) {
console.log(err);
}