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