From: Dessalines Date: Fri, 10 Jul 2020 00:03:47 +0000 (-0400) Subject: Redirect to login page for votes, comments, pages, etc. Fixes #849 (#926) X-Git-Url: http://these/git/%22%7Burl%7D/%7B%60%24%7BghostArchiveUrl%7D/%7B%60/feeds/inbox/%24%7BUserService.Instance.auth%7D.xml%60%7D?a=commitdiff_plain;h=50e6d81d0b40e1d9caa0db83d20026adf3aef631;p=lemmy.git Redirect to login page for votes, comments, pages, etc. Fixes #849 (#926) --- diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 32bc3786..a433dbd4 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -1,4 +1,5 @@ import { Component, linkEvent } from 'inferno'; +import { Link } from 'inferno-router'; import { Subscription } from 'rxjs'; import { retryWhen, delay, take } from 'rxjs/operators'; import { Prompt } from 'inferno-router'; @@ -25,6 +26,7 @@ import autosize from 'autosize'; import Tribute from 'tributejs/src/Tribute.js'; import emojiShortName from 'emoji-short-name'; import { i18n } from '../i18next'; +import { T } from 'inferno-i18next'; interface CommentFormProps { postId?: number; @@ -99,29 +101,31 @@ export class CommentForm extends Component { componentDidMount() { let textarea: any = document.getElementById(this.id); - autosize(textarea); - this.tribute.attach(textarea); - textarea.addEventListener('tribute-replaced', () => { - this.state.commentForm.content = textarea.value; - this.setState(this.state); - autosize.update(textarea); - }); + if (textarea) { + autosize(textarea); + this.tribute.attach(textarea); + textarea.addEventListener('tribute-replaced', () => { + this.state.commentForm.content = textarea.value; + this.setState(this.state); + autosize.update(textarea); + }); - // Quoting of selected text - let selectedText = window.getSelection().toString(); - if (selectedText) { - let quotedText = - selectedText - .split('\n') - .map(t => `> ${t}`) - .join('\n') + '\n\n'; - this.state.commentForm.content = quotedText; - this.setState(this.state); - // Not sure why this needs a delay - setTimeout(() => autosize.update(textarea), 10); - } + // Quoting of selected text + let selectedText = window.getSelection().toString(); + if (selectedText) { + let quotedText = + selectedText + .split('\n') + .map(t => `> ${t}`) + .join('\n') + '\n\n'; + this.state.commentForm.content = quotedText; + this.setState(this.state); + // Not sure why this needs a delay + setTimeout(() => autosize.update(textarea), 10); + } - textarea.focus(); + textarea.focus(); + } } componentDidUpdate() { @@ -144,115 +148,128 @@ export class CommentForm extends Component { when={this.state.commentForm.content} message={i18n.t('block_leaving')} /> -
-
-
-