diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2021-06-03 20:16:48 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2021-06-03 20:16:48 +0000 |
| commit | 2725a0c6398a876590b458ff1a8d6c2cc9af1d11 (patch) | |
| tree | 48ee536d6f931f1cd8b76e4ede75639b39c28501 /src/components/shout_panel/shout_panel.js | |
| parent | 7bd18cda64e0a4ca7a61ff2cf69714f23281e9d9 (diff) | |
| parent | bd98ecb3f0e3d37d7286221a6508a059394b94f2 (diff) | |
Merge branch 'chore/rename-chat' into 'develop'
Rename legacy PleromaFE Chat functionality to "Shout"
See merge request pleroma/pleroma-fe!1207
Diffstat (limited to 'src/components/shout_panel/shout_panel.js')
| -rw-r--r-- | src/components/shout_panel/shout_panel.js | 53 |
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 |
