logo

pleroma-fe

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

shout_panel.js (1292B)


  1. import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
  2. import { library } from '@fortawesome/fontawesome-svg-core'
  3. import {
  4. faBullhorn,
  5. faTimes
  6. } from '@fortawesome/free-solid-svg-icons'
  7. library.add(
  8. faBullhorn,
  9. faTimes
  10. )
  11. const shoutPanel = {
  12. props: ['floating'],
  13. data () {
  14. return {
  15. currentMessage: '',
  16. channel: null,
  17. collapsed: true
  18. }
  19. },
  20. computed: {
  21. messages () {
  22. return this.$store.state.shout.messages
  23. }
  24. },
  25. methods: {
  26. submit (message) {
  27. this.$store.state.shout.channel.push('new_msg', { text: message }, 10000)
  28. this.currentMessage = ''
  29. },
  30. togglePanel () {
  31. this.collapsed = !this.collapsed
  32. },
  33. userProfileLink (user) {
  34. return generateProfileLink(user.id, user.username, this.$store.state.instance.restrictedNicknames)
  35. }
  36. },
  37. watch: {
  38. messages (newVal) {
  39. const scrollEl = this.$el.querySelector('.chat-window')
  40. if (!scrollEl) return
  41. if (scrollEl.scrollTop + scrollEl.offsetHeight + 20 > scrollEl.scrollHeight) {
  42. this.$nextTick(() => {
  43. if (!scrollEl) return
  44. scrollEl.scrollTop = scrollEl.scrollHeight - scrollEl.offsetHeight
  45. })
  46. }
  47. }
  48. }
  49. }
  50. export default shoutPanel