logo

pleroma-fe

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

shout_panel.js (1319B)


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