Skip to content

Commit

Permalink
Add new message notification tone #655
Browse files Browse the repository at this point in the history
  • Loading branch information
idanyadgar committed Jun 24, 2018
1 parent 547c4b0 commit a957e3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion views/src/components/sub-components/AppChatButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<small>Chat</small>
</span>
</span>
<audio src="static/new-message-tone.mp3" hidden preload="auto" ref="audio"></audio>
</v-btn>
</template>

Expand All @@ -20,9 +21,15 @@
return {
newMessages: 0,
intervalHandler: null,
pageDefaultTitle: document.title
pageDefaultTitle: document.title,
audioLoaded: false
}
},
mounted() {
this.$refs.audio.addEventListener("canplaythrough", () => {
this.audioLoaded = true;
});
},
methods: {
nullifyMessages() {
if (this.newMessages > 0) {
Expand All @@ -35,6 +42,10 @@
},
sockets: {
chat_message(m) {
if (!document.hasFocus() && this.audioLoaded) {
this.$refs.audio.play();
}
if (this.$router.history.current.name === 'AppChat') {
return;
}
Expand Down
Binary file added views/static/new-message-tone.mp3
Binary file not shown.

0 comments on commit a957e3e

Please sign in to comment.