Thread.vue 656 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <li
  3. class="thread-list-item"
  4. :class="{ active: isCurrentThread }"
  5. @click="switchThread(thread.id)">
  6. <h5 class="thread-name">{{ thread.name }}</h5>
  7. <div class="thread-time">
  8. {{ thread.lastMessage.timestamp | time }}
  9. </div>
  10. <div class="thread-last-message">
  11. {{ thread.lastMessage.text }}
  12. </div>
  13. </li>
  14. </template>
  15. <script>
  16. import { switchThread } from '../vuex/actions'
  17. export default {
  18. props: ['thread'],
  19. vuex: {
  20. state: {
  21. isCurrentThread ({ currentThreadID }) {
  22. return this.thread.id === currentThreadID
  23. }
  24. },
  25. actions: {
  26. switchThread
  27. }
  28. }
  29. }
  30. </script>