Skip to content

Commit

Permalink
v1.18.7 - Chat Alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
DispatchCommit committed May 23, 2020
1 parent d436a64 commit 5d93b75
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 37 deletions.
32 changes: 25 additions & 7 deletions components/Chat/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
this.socket.on( 'update usernames', async () => await this.updateViewers() );
this.socket.on( 'bulkmessage', async data => await this.rcvMessageBulk( data ) );
this.socket.on( 'alert', async data => await this.addAlert( data ) );
this.socket.on( 'blocked', data => this.setMessage( data.message ) );
this.socket.on( 'pollstate', data => this.updatePoll( data ) );
Expand Down Expand Up @@ -450,20 +451,22 @@
async rcvMessageBulk ( messages ) {
const pattern = new RegExp( `@${this.username}\\b`, 'gi' );
messages.forEach( el => {
messages.forEach( m => {
// Filter messages
if ( this.filterMessage( el ) ) return;
if ( this.filterMessage( m ) ) return;
// Notification Sounds
if ( this.notify ) if ( pattern.test( el.message ) ) this.sound.play().then();
if ( this.notify ) if ( pattern.test( m.message ) ) this.sound.play().then();
// For Text to Speech
const currentChat = el.channel.toLowerCase() === this.username.toLowerCase();
const myChat = el.channel.toLowerCase() === this.page.toLowerCase();
if ( currentChat || myChat ) this.speak( el.message, el.username ); // Say Message
const currentChat = m.channel.toLowerCase() === this.username.toLowerCase();
const myChat = m.channel.toLowerCase() === this.page.toLowerCase();
if ( currentChat || myChat ) this.speak( m.message, m.username ); // Say Message
m.type = 'message';
// Add message to list
this.messages.push( Object.freeze( el ) );
this.messages.push( Object.freeze( m ) );
// Track message count
if ( this.statInterval ) this.newMessageCount++;
Expand All @@ -488,6 +491,21 @@
}
},
addAlert ( data ) {
const m = {
_id: data._id,
type: 'alert',
message: data.message,
color: 'primary',
};
this.messages.push( Object.freeze( m ) );
if ( !this.$refs['chatmessages'].showFAB ) {
this.$nextTick( () => this.scrollToBottom() );
}
},
filterMessage ( message ) {
// Remove ignored user messages
Expand Down
81 changes: 52 additions & 29 deletions components/Chat/ChatMessages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,62 @@
:key="msg._id"
class="pb-1 pl-3 pr-1"
>
<!-- Regular chat message -->
<chat-message
v-if="msg.username !== ( index && messages[ index - 1 ].username )"
:badge="msg.badge"
:username="msg.username"
:display-name="msg.username"
:user-styling="{ color: msg.userColor ? msg.userColor : '#9e9e9e' }"
:route-prefix="routePrefix"
:channel="msg.channel"
:timestamp="getTime( msg.timestamp )"
:avatar="msg.avatar"
:color="msg.color"
:global="getGlobalTag( msg.global )"
@reply="addUserTag"
@whisper="addWhisper"
@select="onMessageClick( msg )"
>
<div
class="body-2 msg"
v-html="msg.message"
></div>
</chat-message>

<!-- Append messages -->
<div
<!-- Chat Alert -->
<template
v-if="msg.type === 'alert'"
>
<div>
<v-alert
dense
outlined
text
border="left"
:color="msg.color"
class="my-2"
>{{ msg.message }}</v-alert>
</div>
</template>

<!-- Chat Message -->
<template
v-else
class="msg append"
>
<!-- Regular chat message -->
<chat-message
v-if="msg.username !== ( index && messages[ index - 1 ].username )"
:badge="msg.badge"
:username="msg.username"
:display-name="msg.username"
:user-styling="{ color: msg.userColor ? msg.userColor : '#9e9e9e' }"
:route-prefix="routePrefix"
:channel="msg.channel"
:timestamp="getTime( msg.timestamp )"
:avatar="msg.avatar"
:color="msg.color"
:global="getGlobalTag( msg.global )"
@reply="addUserTag"
@whisper="addWhisper"
@select="onMessageClick( msg )"
>
<div
class="body-2 msg"
v-html="msg.message"
></div>
</chat-message>

<!-- Append messages -->
<div
class="body-2 msg"
v-html="msg.message"
></div>
</div>
v-else
class="msg append"
>
<div
class="body-2 msg"
v-html="msg.message"
></div>
</div>
</template>

</div>

</transition-group>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitwave.tv",
"version": "1.18.6",
"version": "1.18.7",
"description": "An open platform live streaming service for creators to freely express themselves.",
"author": "Dispatch",
"scripts": {
Expand Down

0 comments on commit 5d93b75

Please sign in to comment.