diff --git a/static/js/conversations.js b/static/js/conversations.js index 5c781c3..7695e23 100644 --- a/static/js/conversations.js +++ b/static/js/conversations.js @@ -1203,6 +1203,19 @@ placeholder: 'Napisz wiadomość...', modules: { toolbar: [['bold', 'italic'], ['link'], ['clean']], + keyboard: { + bindings: { + enter: { + key: 13, + handler: function() { Composer.send(); return false; } + }, + shiftEnter: { + key: 13, + shiftKey: true, + handler: function() { return true; } // Allow newline + } + } + } }, }); @@ -1211,7 +1224,9 @@ if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); e.stopPropagation(); + e.stopImmediatePropagation(); Composer.send(); + return false; } }); @@ -1254,12 +1269,14 @@ send: async function () { if (!state.currentConversationId || !state.quill) return; + if (state._isSending) return; // Prevent double send var html = state.quill.root.innerHTML; var text = state.quill.getText().trim(); if (!text && !state.attachedFiles.length) return; + state._isSending = true; var convId = state.currentConversationId; try { @@ -1296,6 +1313,8 @@ }); } catch (e) { alert('Nie udało się wysłać wiadomości: ' + e.message); + } finally { + state._isSending = false; } }, @@ -1963,6 +1982,8 @@ alert('Wybierz co najmniej jednego odbiorcę'); return; } + if (state._isCreating) return; // Prevent double send + state._isCreating = true; var messageContent = ''; if (state.newMessageQuill) { @@ -2005,6 +2026,8 @@ ConversationList.selectConversation(result.id); } catch (e) { alert('Nie udało się utworzyć konwersacji: ' + e.message); + } finally { + state._isCreating = false; } }, };