2018-12-13 03:00:01 +01:00
|
|
|
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
2020-10-19 21:35:46 +02:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
2020-10-20 20:18:23 +02:00
|
|
|
import {
|
|
|
|
faBullhorn,
|
|
|
|
faTimes
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
2020-10-19 21:35:46 +02:00
|
|
|
|
|
|
|
library.add(
|
2020-10-20 20:18:23 +02:00
|
|
|
faBullhorn,
|
|
|
|
faTimes
|
2020-10-19 21:35:46 +02:00
|
|
|
)
|
2018-12-13 03:00:01 +01:00
|
|
|
|
2020-08-04 01:44:35 +02:00
|
|
|
const shoutPanel = {
|
2022-07-31 11:35:48 +02:00
|
|
|
props: ['floating'],
|
2017-12-05 11:02:41 +01:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
currentMessage: '',
|
2018-04-10 23:17:05 +02:00
|
|
|
channel: null,
|
2018-04-24 09:48:30 +02:00
|
|
|
collapsed: true
|
2017-12-05 11:02:41 +01:00
|
|
|
}
|
|
|
|
},
|
2017-12-05 11:47:10 +01:00
|
|
|
computed: {
|
|
|
|
messages () {
|
2020-08-04 01:44:35 +02:00
|
|
|
return this.$store.state.shout.messages
|
2017-12-05 11:47:10 +01:00
|
|
|
}
|
2017-12-05 11:02:41 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2017-12-05 11:49:40 +01:00
|
|
|
submit (message) {
|
2020-08-04 01:44:35 +02:00
|
|
|
this.$store.state.shout.channel.push('new_msg', { text: message }, 10000)
|
2017-12-05 11:49:40 +01:00
|
|
|
this.currentMessage = ''
|
2018-04-10 23:17:05 +02:00
|
|
|
},
|
|
|
|
togglePanel () {
|
|
|
|
this.collapsed = !this.collapsed
|
2018-12-17 00:52:27 +01:00
|
|
|
},
|
|
|
|
userProfileLink (user) {
|
2018-12-29 15:25:45 +01:00
|
|
|
return generateProfileLink(user.id, user.username, this.$store.state.instance.restrictedNicknames)
|
2017-12-05 11:02:41 +01:00
|
|
|
}
|
2021-03-03 15:46:53 +01:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
messages (newVal) {
|
|
|
|
const scrollEl = this.$el.querySelector('.chat-window')
|
|
|
|
if (!scrollEl) return
|
|
|
|
if (scrollEl.scrollTop + scrollEl.offsetHeight + 20 > scrollEl.scrollHeight) {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
if (!scrollEl) return
|
|
|
|
scrollEl.scrollTop = scrollEl.scrollHeight - scrollEl.offsetHeight
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2017-12-05 11:02:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 01:44:35 +02:00
|
|
|
export default shoutPanel
|