|
|
@ -46506,22 +46506,33 @@ module.exports = { |
|
|
|
|
|
|
|
// Listen for new items on the queue
|
|
|
|
Echo.channel('tweet-queue').listen('NewTweetEvent', function (e) { |
|
|
|
console.log(e); |
|
|
|
_this.queue.push(e); |
|
|
|
if (_this.findTweetInQueue(e.tweet_id) === false) { |
|
|
|
_this.queue.push(e); |
|
|
|
} |
|
|
|
}).listen('TweetClaimedEvent', function (e) { |
|
|
|
_this.removeTweetFromQueue(e.tweet_id); |
|
|
|
}); |
|
|
|
}.bind(this)); |
|
|
|
}, |
|
|
|
clickedTweet: function clickedTweet(event) { |
|
|
|
var tweet_id = $(event.target).parents(".tweet").data('tweet-id'); |
|
|
|
console.log(this.queue); |
|
|
|
// Get the index of the clicked element
|
|
|
|
findTweetInQueue: function findTweetInQueue(tweet_id) { |
|
|
|
var queueIndex = false; |
|
|
|
for (var i in this.queue) { |
|
|
|
if (parseInt(this.queue[i].tweet_id) == parseInt(tweet_id)) { |
|
|
|
var queueIndex = i; |
|
|
|
queueIndex = i; |
|
|
|
} |
|
|
|
} |
|
|
|
console.log("Removing item at index " + queueIndex); |
|
|
|
this.queue.splice(queueIndex, 1); |
|
|
|
return queueIndex; |
|
|
|
}, |
|
|
|
removeTweetFromQueue: function removeTweetFromQueue(tweet_id) { |
|
|
|
var queueIndex = this.findTweetInQueue(tweet_id); |
|
|
|
if (queueIndex !== false) { |
|
|
|
console.log("Removing item at index " + queueIndex); |
|
|
|
this.queue.splice(queueIndex, 1); |
|
|
|
} |
|
|
|
}, |
|
|
|
clickedTweet: function clickedTweet(event) { |
|
|
|
var tweet_id = $(event.target).parents(".tweet").data('tweet-id'); |
|
|
|
this.removeTweetFromQueue(tweet_id); |
|
|
|
|
|
|
|
// Mark this as claimed
|
|
|
|
$.post('/dashboard/claim-tweet', { |
|
|
|