diff options
author | Dessalines <tyhou13@gmx.com> | 2020-01-30 21:15:58 -0500 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-01-30 21:15:58 -0500 |
commit | 5188bddd4ddb1d4f4bc4add24db210789054c2a5 (patch) | |
tree | f68f8cebb4189acb591bbd129fa052b1d09619d6 /ui/src/components | |
parent | 65adb0d15dcb10382dadca2694ee17b206c384fd (diff) | |
parent | 8cbdba1da39c15d2a3d13919398fc4d4c8ef2c6c (diff) |
Merge branch 'dev' into websocket_scopes
Diffstat (limited to 'ui/src/components')
-rw-r--r-- | ui/src/components/comment-form.tsx | 18 | ||||
-rw-r--r-- | ui/src/components/community.tsx | 11 | ||||
-rw-r--r-- | ui/src/components/inbox.tsx | 4 | ||||
-rw-r--r-- | ui/src/components/navbar.tsx | 2 | ||||
-rw-r--r-- | ui/src/components/post-form.tsx | 18 | ||||
-rw-r--r-- | ui/src/components/post.tsx | 25 |
6 files changed, 66 insertions, 12 deletions
diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index e4543d66..7eb30f50 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -96,6 +96,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> { className={`form-control ${this.state.previewMode && 'd-none'}`} value={this.state.commentForm.content} onInput={linkEvent(this, this.handleCommentContentChange)} + onPaste={linkEvent(this, this.handleImageUploadPaste)} required disabled={this.props.disabled} rows={2} @@ -208,9 +209,22 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> { i.props.onReplyCancel(); } + handleImageUploadPaste(i: CommentForm, event: any) { + let image = event.clipboardData.files[0]; + if (image) { + i.handleImageUpload(i, image); + } + } + handleImageUpload(i: CommentForm, event: any) { - event.preventDefault(); - let file = event.target.files[0]; + let file: any; + if (event.target) { + event.preventDefault(); + file = event.target.files[0]; + } else { + file = event; + } + const imageUploadUrl = `/pictshare/api/upload.php`; const formData = new FormData(); formData.append('file', file); diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 221c9211..3c5f6890 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -11,6 +11,7 @@ import { SortType, Post, GetPostsForm, + GetCommunityForm, ListingType, GetPostsResponse, CreatePostLikeResponse, @@ -98,11 +99,11 @@ export class Community extends Component<any, State> { () => console.log('complete') ); - if (this.state.communityId) { - WebSocketService.Instance.getCommunity(this.state.communityId); - } else if (this.state.communityName) { - WebSocketService.Instance.getCommunityByName(this.state.communityName); - } + let form: GetCommunityForm = { + id: this.state.communityId ? this.state.communityId : null, + name: this.state.communityName ? this.state.communityName : null, + }; + WebSocketService.Instance.getCommunity(form); } componentWillUnmount() { diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx index ba5cc6ad..41c1ce60 100644 --- a/ui/src/components/inbox.tsx +++ b/ui/src/components/inbox.tsx @@ -38,6 +38,8 @@ enum UnreadType { Messages, } +type ReplyType = Comment | PrivateMessageI; + interface InboxState { unreadOrAll: UnreadOrAll; unreadType: UnreadType; @@ -186,7 +188,7 @@ export class Inbox extends Component<any, InboxState> { } all() { - let combined: Array<Comment | PrivateMessageI> = []; + let combined: Array<ReplyType> = []; combined.push(...this.state.replies); combined.push(...this.state.mentions); diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index 18ba98c9..1828fce9 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -138,7 +138,7 @@ export class Navbar extends Component<any, NavbarState> { </li> <li className="nav-item"> <Link - class="nav-link ml-2" + class="nav-link" to="/sponsors" title={i18n.t('donate_to_lemmy')} > diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index ebc7d7b7..57d9a964 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -160,6 +160,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> { class="form-control" value={this.state.postForm.url} onInput={linkEvent(this, this.handlePostUrlChange)} + onPaste={linkEvent(this, this.handleImageUploadPaste)} /> {this.state.suggestedTitle && ( <div @@ -442,9 +443,22 @@ export class PostForm extends Component<PostFormProps, PostFormState> { i.setState(i.state); } + handleImageUploadPaste(i: PostForm, event: any) { + let image = event.clipboardData.files[0]; + if (image) { + i.handleImageUpload(i, image); + } + } + handleImageUpload(i: PostForm, event: any) { - event.preventDefault(); - let file = event.target.files[0]; + let file: any; + if (event.target) { + event.preventDefault(); + file = event.target.files[0]; + } else { + file = event; + } + const imageUploadUrl = `/pictshare/api/upload.php`; const formData = new FormData(); formData.append('file', file); diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index f57d8913..36621248 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -23,6 +23,7 @@ import { SearchType, SortType, SearchForm, + GetPostForm, SearchResponse, GetSiteResponse, GetCommunityResponse, @@ -84,7 +85,10 @@ export class Post extends Component<any, PostState> { () => console.log('complete') ); - WebSocketService.Instance.getPost(postId); + let form: GetPostForm = { + id: postId, + }; + WebSocketService.Instance.getPost(form); } componentWillUnmount() { @@ -231,6 +235,18 @@ export class Post extends Component<any, PostState> { onChange={linkEvent(this, this.handleCommentSortChange)} /> </label> + <label + className={`btn btn-sm btn-secondary pointer ${this.state + .commentSort === CommentSortType.Old && 'active'}`} + > + {i18n.t('old')} + <input + type="radio" + value={CommentSortType.Old} + checked={this.state.commentSort === CommentSortType.Old} + onChange={linkEvent(this, this.handleCommentSortChange)} + /> + </label> </div> ); } @@ -313,6 +329,13 @@ export class Post extends Component<any, PostState> { +a.comment.deleted - +b.comment.deleted || b.comment.published.localeCompare(a.comment.published) ); + } else if (this.state.commentSort == CommentSortType.Old) { + tree.sort( + (a, b) => + +a.comment.removed - +b.comment.removed || + +a.comment.deleted - +b.comment.deleted || + a.comment.published.localeCompare(b.comment.published) + ); } else if (this.state.commentSort == CommentSortType.Hot) { tree.sort( (a, b) => |