refactor: clear quick reply as soon as submitting

bring back message on error
This commit is contained in:
Barış Soner Uşaklı
2025-12-18 10:47:55 -05:00
parent b405a09bfd
commit a331f8da77

View File

@@ -60,7 +60,7 @@ define('quickreply', [
return; return;
} }
const replyMsg = components.get('topic/quickreply/text').val(); const replyMsg = element.val();
const replyData = { const replyData = {
tid: ajaxify.data.tid, tid: ajaxify.data.tid,
handle: undefined, handle: undefined,
@@ -74,9 +74,11 @@ define('quickreply', [
} }
ready = false; ready = false;
element.val('');
api.post(`/topics/${ajaxify.data.tid}`, replyData, function (err, data) { api.post(`/topics/${ajaxify.data.tid}`, replyData, function (err, data) {
ready = true; ready = true;
if (err) { if (err) {
element.val(replyMsg);
return alerts.error(err); return alerts.error(err);
} }
if (data && data.queued) { if (data && data.queued) {
@@ -91,7 +93,7 @@ define('quickreply', [
}); });
} }
components.get('topic/quickreply/text').val(''); element.val('');
storage.removeItem(qrDraftId); storage.removeItem(qrDraftId);
QuickReply._autocomplete.hide(); QuickReply._autocomplete.hide();
hooks.fire('action:quickreply.success', { data }); hooks.fire('action:quickreply.success', { data });