diff --git a/js/src/forum/components/ReplyPlaceholder.js b/js/src/forum/components/ReplyPlaceholder.js index ce7107a2b..23729799e 100644 --- a/js/src/forum/components/ReplyPlaceholder.js +++ b/js/src/forum/components/ReplyPlaceholder.js @@ -4,7 +4,7 @@ import Component from '../../common/Component'; import avatar from '../../common/helpers/avatar'; import username from '../../common/helpers/username'; import DiscussionControls from '../utils/DiscussionControls'; -import ReplyPlaceholderPreview from './ReplyPlaceholderPreview'; +import ComposerPostPreview from './ComposerPostPreview'; /** * The `ReplyPlaceholder` component displays a placeholder for a reply, which, @@ -27,7 +27,7 @@ export default class ReplyPlaceholder extends Component { - + ); } @@ -44,4 +44,14 @@ export default class ReplyPlaceholder extends Component { ); } + + anchorPreview(preview) { + const anchorToBottom = $(window).scrollTop() + $(window).height() >= $(document).height(); + + preview(); + + if (anchorToBottom) { + $(window).scrollTop($(document).height()); + } + } } diff --git a/js/src/forum/components/ReplyPlaceholderPreview.js b/js/src/forum/components/ReplyPlaceholderPreview.js deleted file mode 100644 index cc99a71a2..000000000 --- a/js/src/forum/components/ReplyPlaceholderPreview.js +++ /dev/null @@ -1,40 +0,0 @@ -/*global s9e*/ - -import Component from '../../common/Component'; - -export default class ReplyPlaceholderPreview extends Component { - view() { - return
; - } - - oncreate(vnode) { - super.oncreate(vnode); - - // Every 50ms, if the composer content has changed, then update the post's - // body with a preview. - let preview; - this.updateInterval = setInterval(() => { - // Since we're polling, the composer may have been closed in the meantime, - // so we bail in that case. - if (!app.composer.isVisible()) return; - - const content = app.composer.fields.content(); - - if (preview === content) return; - - preview = content; - - const anchorToBottom = $(window).scrollTop() + $(window).height() >= $(document).height(); - - s9e.TextFormatter.preview(preview || '', vnode.dom); - - if (anchorToBottom) { - $(window).scrollTop($(document).height()); - } - }, 50); - } - - onremove() { - clearInterval(this.updateInterval); - } -}