logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

chat_list_item.js (2001B)


  1. import { mapState } from 'vuex'
  2. import StatusBody from '../status_content/status_content.vue'
  3. import fileType from 'src/services/file_type/file_type.service'
  4. import UserAvatar from '../user_avatar/user_avatar.vue'
  5. import AvatarList from '../avatar_list/avatar_list.vue'
  6. import Timeago from '../timeago/timeago.vue'
  7. import ChatTitle from '../chat_title/chat_title.vue'
  8. const ChatListItem = {
  9. name: 'ChatListItem',
  10. props: [
  11. 'chat'
  12. ],
  13. components: {
  14. UserAvatar,
  15. AvatarList,
  16. Timeago,
  17. ChatTitle,
  18. StatusBody
  19. },
  20. computed: {
  21. ...mapState({
  22. currentUser: state => state.users.currentUser
  23. }),
  24. attachmentInfo () {
  25. if (this.chat.lastMessage.attachments.length === 0) { return }
  26. const types = this.chat.lastMessage.attachments.map(file => fileType.fileType(file.mimetype))
  27. if (types.includes('video')) {
  28. return this.$t('file_type.video')
  29. } else if (types.includes('audio')) {
  30. return this.$t('file_type.audio')
  31. } else if (types.includes('image')) {
  32. return this.$t('file_type.image')
  33. } else {
  34. return this.$t('file_type.file')
  35. }
  36. },
  37. messageForStatusContent () {
  38. const message = this.chat.lastMessage
  39. const messageEmojis = message ? message.emojis : []
  40. const isYou = message && message.account_id === this.currentUser.id
  41. const content = message ? (this.attachmentInfo || message.content) : ''
  42. const messagePreview = isYou ? `<i>${this.$t('chats.you')}</i> ${content}` : content
  43. return {
  44. summary: '',
  45. emojis: messageEmojis,
  46. raw_html: messagePreview,
  47. text: messagePreview,
  48. attachments: []
  49. }
  50. }
  51. },
  52. methods: {
  53. openChat (_e) {
  54. if (this.chat.id) {
  55. this.$router.push({
  56. name: 'chat',
  57. params: {
  58. username: this.currentUser.screen_name,
  59. recipient_id: this.chat.account.id
  60. }
  61. })
  62. }
  63. }
  64. }
  65. }
  66. export default ChatListItem