Thread.vue 643 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <li
  3. class="thread-list-item"
  4. :class="{ active: isCurrentThread }"
  5. @click="onClick">
  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 store from '../store'
  17. export default {
  18. props: ['thread'],
  19. computed: {
  20. isCurrentThread () {
  21. return this.thread.id === store.state.currentThreadID
  22. }
  23. },
  24. methods: {
  25. onClick () {
  26. store.actions.switchThread(this.thread.id)
  27. }
  28. }
  29. }
  30. </script>