ThreadSection.vue 775 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 store from '../store'
  19. import Thread from './Thread.vue'
  20. export default {
  21. components: { Thread },
  22. computed: {
  23. threads () {
  24. return store.state.threads
  25. },
  26. unreadCount () {
  27. const threads = store.state.threads
  28. return Object.keys(threads).reduce((count, id) => {
  29. return threads[id].lastMessage.isRead
  30. ? count
  31. : count + 1
  32. }, 0)
  33. }
  34. }
  35. }
  36. </script>