From 091138cdd927dc7d353e74f418f8413df33da98a Mon Sep 17 00:00:00 2001 From: Saurabh Rawat Date: Fri, 6 Jul 2018 22:03:57 +0530 Subject: [PATCH] fix accidental double entry for sent messages --- gitterapi.js | 10 +++++----- main.qml | 6 +----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gitterapi.js b/gitterapi.js index 2fa2dcc..921762c 100644 --- a/gitterapi.js +++ b/gitterapi.js @@ -72,7 +72,7 @@ function markRead(token, userId, roomId, msgIds) { xhr.send({"chat": JSON.stringify(msgIds)}); } -function sendMessage(token, roomId, m, onSuccess) { +function sendMessage(token, roomId, m) { print(token, roomId, m); var xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.gitter.im/v1/rooms/" + roomId + "/chatMessages", true); @@ -81,10 +81,10 @@ function sendMessage(token, roomId, m, onSuccess) { xhr.onreadystatechange = function() { if(xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status !== 200) print(xhr.statusText, xhr.responseText) - if (xhr.status === 200) { - var message = JSON.parse(xhr.responseText); - onSuccess(roomId, message); - } +// if (xhr.status === 200) { +// var message = JSON.parse(xhr.responseText); +// onSuccess(roomId, message); +// } } } var body = JSON.stringify({"text": m}); diff --git a/main.qml b/main.qml index c5007bd..8ce27b0 100644 --- a/main.qml +++ b/main.qml @@ -519,11 +519,7 @@ Window { } function sendMessage() { - Gitter.sendMessage(settings.token, window.curRoom, curMsg.text, - function (rmId, message) { - msgs.model.append(message) - saveMessage(rmId, message) - }) + Gitter.sendMessage(settings.token, window.curRoom, curMsg.text) curMsg.text = "" }