1
0

ThreadSection.vue 756 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <div class="thread-section">
  3. <div class="thread-count">
  4. <span v-show="unreadCount">
  5. Unread threads: {{ unreadCount }}
  6. </span>
  7. </div>
  8. <ul class="thread-list">
  9. <thread
  10. v-for="thread in threads"
  11. track-by="id"
  12. :thread="thread">
  13. </thread>
  14. </ul>
  15. </div>
  16. </template>
  17. <script>
  18. import Thread from './Thread.vue'
  19. export default {
  20. components: { Thread },
  21. vuex: {
  22. getters: {
  23. threads: state => state.threads
  24. }
  25. },
  26. computed: {
  27. unreadCount () {
  28. const threads = this.threads
  29. return Object.keys(threads).reduce((count, id) => {
  30. return threads[id].lastMessage.isRead
  31. ? count
  32. : count + 1
  33. }, 0)
  34. }
  35. }
  36. }
  37. </script>