ThreadSection.vue 935 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. :key="thread.id"
  12. :thread="thread"
  13. :active="thread.id === currentThread.id"
  14. @switch-thread="switchThread">
  15. </thread>
  16. </ul>
  17. </div>
  18. </template>
  19. <script>
  20. import { computed } from 'vue'
  21. import { useStore } from 'vuex'
  22. import Thread from './Thread.vue'
  23. export default {
  24. name: 'ThreadSection',
  25. components: { Thread },
  26. setup () {
  27. const store = useStore()
  28. return {
  29. threads: computed(() => store.getters.threads),
  30. currentThread: computed(() => store.getters.currentThread),
  31. unreadCount: computed(() => store.getters.unreadCount),
  32. switchThread: (id) => store.dispatch('switchThread', id)
  33. }
  34. }
  35. }
  36. </script>