You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

<template>
<div class="tweet-queue">
<div v-for="tweet in queue" v-on:click="clickedTweet" class="tweet" :data-tweet-id="tweet.tweet_id">
<div class="profile">
<img :src="tweet.player_photo" :style="'border-color: #'+tweet.team_color">
<span><a :href="'https://twitter.com/'+tweet.player_username">@{{ tweet.player_username }}</a></span>
</div>
<div class="mission" :data-mission-id="tweet.mission_id">{{ tweet.mission }}</div>
<div class="text">{{ tweet.text }}</div>
</div>
</div>
</template>
<script>
module.exports = {
data () {
return {
queue: []
}
},
methods: {
loadQueue () {
$.get('/dashboard/queue', function(tweets){
for(var i in tweets.queue) {
this.queue.push(tweets.queue[i]);
}
// Listen for new items on the queue
Echo.channel('tweet-queue')
.listen('NewTweetEvent', (e) => {
console.log(e);
this.queue.push(e);
});
}.bind(this));
},
clickedTweet(event) {
var tweet_id = $(event.target).parents(".tweet").data('tweet-id');
console.log(this.queue);
// Get the index of the clicked element
for(var i in this.queue) {
if(parseInt(this.queue[i].tweet_id) == parseInt(tweet_id)) {
var queueIndex = i;
}
}
console.log("Removing item at index "+queueIndex);
this.queue.splice(queueIndex, 1);
// Mark this as claimed
$.post('/dashboard/claim-tweet', {
tweet_id: tweet_id
}, function(response) {
});
}
},
created() {
this.loadQueue();
}
}
</script>