Skip to content

Commit

Permalink
fix accidental double entry for sent messages
Browse files Browse the repository at this point in the history
  • Loading branch information
eklavya committed Jul 6, 2018
1 parent 48feb19 commit 091138c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
10 changes: 5 additions & 5 deletions gitterapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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});
Expand Down
6 changes: 1 addition & 5 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}

Expand Down

0 comments on commit 091138c

Please sign in to comment.