Fix multiple calls on message edit
This commit is contained in:
@@ -999,34 +999,39 @@ function toggleEditButton()
|
|||||||
function editMessage()
|
function editMessage()
|
||||||
{
|
{
|
||||||
let $Editable = $(this);
|
let $Editable = $(this);
|
||||||
if($Editable.prop('contenteditable') != 'true')
|
$Editable.prop('contenteditable', 'true').focus();
|
||||||
|
|
||||||
|
if($Editable.data('backup') == null)
|
||||||
{
|
{
|
||||||
$Editable
|
$Editable
|
||||||
.data('backup', $Editable.text())
|
.data('backup', $Editable.text())
|
||||||
.prop('contenteditable', 'true')
|
.on('focusout keydown', function(e) {
|
||||||
.focus();
|
if(e.type == 'focusout' || e.which == 13) {
|
||||||
|
e.preventDefault();
|
||||||
$Editable.on('focusout keydown', function(e) {
|
var sOldMsg = $Editable.data('backup');
|
||||||
if(e.type == 'focusout' || e.which == 13) {
|
var sNewMsg = $Editable.text();
|
||||||
e.preventDefault();
|
if(sOldMsg != sNewMsg) {
|
||||||
$(this).prop('contenteditable', 'false');
|
$Editable.data('backup', sNewMsg);
|
||||||
databap.getInfo
|
$Editable.prop('contenteditable', 'false');
|
||||||
(
|
databap.getInfo
|
||||||
'edit_message',
|
(
|
||||||
function(asResult)
|
'edit_message',
|
||||||
{
|
function(asResult)
|
||||||
refresh_chat();
|
{
|
||||||
$MsgInput.focus();
|
refresh_chat();
|
||||||
},
|
$MsgInput.focus();
|
||||||
{message_id: $Editable.parents('p.U').data('id'), message: $Editable.text()},
|
},
|
||||||
'json',
|
{message_id: $Editable.parents('p.U').data('id'), message: sNewMsg},
|
||||||
function(textStatus)
|
'json',
|
||||||
{
|
function(textStatus)
|
||||||
databap.showError(textStatus);
|
{
|
||||||
|
$Editable.data('backup', sOldMsg);
|
||||||
|
databap.showError(textStatus);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user