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