aboutsummaryrefslogtreecommitdiff
path: root/src/components/shout_panel/shout_panel.js
diff options
context:
space:
mode:
authorIlja <ilja@ilja.space>2022-02-26 02:08:13 +0100
committerIlja <ilja@ilja.space>2022-02-26 02:08:13 +0100
commitd0c4ad22cd5a93f69c689f3c8c75546c35861740 (patch)
tree15b535925b4ce0ea851e27ace32afde9db6a29c1 /src/components/shout_panel/shout_panel.js
parent819b76026101ddc0363118f240049a0019ebb4d6 (diff)
parent0300db6c6356c536694a9fcbb32a52abc81c52d5 (diff)
Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma-fe into feat/report-notification
Diffstat (limited to 'src/components/shout_panel/shout_panel.js')
-rw-r--r--src/components/shout_panel/shout_panel.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/components/shout_panel/shout_panel.js b/src/components/shout_panel/shout_panel.js
new file mode 100644
index 00000000..a6168971
--- /dev/null
+++ b/src/components/shout_panel/shout_panel.js
@@ -0,0 +1,53 @@
+import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
+import { library } from '@fortawesome/fontawesome-svg-core'
+import {
+ faBullhorn,
+ faTimes
+} from '@fortawesome/free-solid-svg-icons'
+
+library.add(
+ faBullhorn,
+ faTimes
+)
+
+const shoutPanel = {
+ props: [ 'floating' ],
+ data () {
+ return {
+ currentMessage: '',
+ channel: null,
+ collapsed: true
+ }
+ },
+ computed: {
+ messages () {
+ return this.$store.state.shout.messages
+ }
+ },
+ methods: {
+ submit (message) {
+ this.$store.state.shout.channel.push('new_msg', { text: message }, 10000)
+ this.currentMessage = ''
+ },
+ togglePanel () {
+ this.collapsed = !this.collapsed
+ },
+ userProfileLink (user) {
+ return generateProfileLink(user.id, user.username, this.$store.state.instance.restrictedNicknames)
+ }
+ },
+ 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
+ })
+ }
+ }
+ }
+}
+
+export default shoutPanel