Commit 35e23641 authored by Killian Kemps's avatar Killian Kemps
Browse files

Fix crash when retweeting an already retweeted tweet

parent cbce7e93
......@@ -88,10 +88,13 @@ module.exports = function(io) {
socket.on('retweet', function(tweetId){
console.log('Log: Got retweet request with id ', localUserId);
users.sendRetweet(localUserId, tweetId, function(retweetedId){
if(retweetedId){
users.sendRetweet(localUserId, tweetId, function(code, data){
if(code === 200){
// socket.emit('retweetedId', retweetedId);
console.log('Log: Retweet sent!');
console.log('Log: Retweet sent with id ', data.id_str, '!');
}
else {
console.log('Log: an error occured while retweeting');
}
});
});
......
......@@ -105,7 +105,14 @@ var twitterAgent = {
T.post('statuses/retweet/:id', { id: tweetId }, function (err, data, response) {
console.log('Err: ', err);
console.log('data: ', data);
cb(data.id_str);
if (err) {
var code = err.code;
}
else {
var code = 200;
}
cb(code, data);
})
},
......
......@@ -346,7 +346,7 @@ Message.prototype.sendRetweet = function(e){
this.applyTweetStatus();
}
var bindedFunction = (sendRetweetCommand).bind(this)
var bindedFunction = (sendRetweetCommand).bind(this);
retweetButton.addEventListener('click', bindedFunction, true);
......@@ -373,7 +373,7 @@ Message.prototype.applyTweetStatus = function(){
for (var i = 0; i < retweetButtons.length; i++) {
retweetButtons[i].removeAttribute("class");
retweetButtons[i].setAttribute('class', 'tweet-retweet-button-active');
// console.log('Updated concerning retweet');
console.log('Updated concerning retweet ', this.id_str);
};
}
else{
......@@ -381,7 +381,7 @@ Message.prototype.applyTweetStatus = function(){
for (var i = 0; i < retweetButtons.length; i++) {
retweetButtons[i].removeAttribute("class");
retweetButtons[i].setAttribute('class', 'tweet-retweet-button');
// console.log('Updated concerning retweet');
console.log('Updated disabled concerning retweet');
};
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment