Skip to content

Commit e30fd3c

Browse files
committed
Clear comment on successful post
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent 8146e19 commit e30fd3c

1 file changed

Lines changed: 22 additions & 19 deletions

File tree

apps/comments/src/commentstabview.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable */
2-
/*
2+
/**
33
* Copyright (c) 2016
44
*
55
* This file is licensed under the Affero General Public License version 3
@@ -264,14 +264,14 @@
264264
},
265265

266266
/**
267-
* takes care of post-rendering after a new comment was added to the
268-
* collection
269-
*
270-
* @param model
271-
* @param collection
272-
* @param options
273-
* @private
274-
*/
267+
* takes care of post-rendering after a new comment was added to the
268+
* collection
269+
*
270+
* @param model
271+
* @param collection
272+
* @param options
273+
* @private
274+
*/
275275
_onAddModel: function(model, collection, options) {
276276
// we need to render it immediately, to ensure that the right
277277
// order of comments is kept on opening comments tab
@@ -303,11 +303,11 @@
303303
},
304304

305305
/**
306-
* takes care of post-rendering after a new comment was edited
307-
*
308-
* @param model
309-
* @private
310-
*/
306+
* takes care of post-rendering after a new comment was edited
307+
*
308+
* @param model
309+
* @private
310+
*/
311311
_onChangeModel: function(model) {
312312
if (model.get('message').trim() === model.previous('message').trim()) {
313313
return
@@ -402,9 +402,9 @@
402402
},
403403

404404
/**
405-
* Convert a message to be displayed in HTML,
406-
* converts newlines to <br> tags.
407-
*/
405+
* Convert a message to be displayed in HTML,
406+
* converts newlines to <br> tags.
407+
*/
408408
_formatMessage: function(message, mentions, editMode) {
409409
message = escapeHTML(message).replace(/\n/g, '<br/>')
410410

@@ -597,9 +597,12 @@
597597
_onSubmitSuccess: function(model, $form) {
598598
var $submit = $form.find('.submit')
599599
var $loading = $form.find('.submitLoading')
600+
var $message = $form.find('.message')
600601

601602
$submit.removeClass('hidden')
602603
$loading.addClass('hidden')
604+
$message.prop('contenteditable', true)
605+
$message.text('')
603606
},
604607

605608
_commentBodyHTML2Plain: function($el) {
@@ -651,15 +654,15 @@
651654

652655
message = this._commentBodyHTML2Plain($commentField)
653656
if (commentId) {
654-
// edit mode
657+
// edit mode
655658
var comment = this.collection.get(commentId)
656659
comment.save({
657660
message: message
658661
}, {
659662
success: function(model) {
660663
self._onSubmitSuccess(model, $form)
661664
if (model.get('message').trim() === model.previous('message').trim()) {
662-
// model change event doesn't trigger, manually remove the row.
665+
// model change event doesn't trigger, manually remove the row.
663666
var $row = $form.closest('.comment')
664667
$row.data('commentEl').removeClass('hidden')
665668
$row.remove()

0 commit comments

Comments
 (0)