diff --git a/package-lock.json b/package-lock.json index 67a731a..55ea6ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3291,7 +3291,7 @@ }, "get-stream": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", "dev": true } @@ -3372,7 +3372,7 @@ "dependencies": { "globby": { "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "resolved": "http://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", "dev": true, "requires": { @@ -3385,7 +3385,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -5251,6 +5251,11 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "futoji": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/futoji/-/futoji-0.2.0.tgz", + "integrity": "sha512-V3q7YwYGisBmr9J0/24yBafW4ClSjbLok/WztF/GtpfVO6K36DCyWMD++68TlyiDN5xxcA+LNue6Zo4iON2BRQ==" + }, "get-caller-file": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", @@ -5713,7 +5718,7 @@ }, "http-proxy-middleware": { "version": "0.18.0", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.18.0.tgz", + "resolved": "http://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.18.0.tgz", "integrity": "sha512-Fs25KVMPAIIcgjMZkVHJoKg9VcXcC1C8yb9JUgeDvVXY0S/zgVIhMb+qVswDIgtJe2DfckMSY2d6TuTEutlk6Q==", "dev": true, "requires": { @@ -7461,7 +7466,7 @@ }, "p-is-promise": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, @@ -10934,7 +10939,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { diff --git a/package.json b/package.json index 92d40f5..83da411 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dependencies": { "@vue/eslint-plugin": "^4.2.0", "axios": "^0.18.0", + "futoji": "^0.2.0", "jquery": "^3.3.1", "socket.io": "^2.2.0", "socket.io-client": "^2.2.0", diff --git a/src/assets/sounds/FriendRequest.mp3 b/src/assets/sounds/FriendRequest.mp3 new file mode 100644 index 0000000..baf6a4a Binary files /dev/null and b/src/assets/sounds/FriendRequest.mp3 differ diff --git a/src/assets/sounds/Notification.mp3 b/src/assets/sounds/Notification.mp3 new file mode 100644 index 0000000..ab867ca Binary files /dev/null and b/src/assets/sounds/Notification.mp3 differ diff --git a/src/changelog.js b/src/changelog.js index 38584f5..853b6dc 100644 --- a/src/changelog.js +++ b/src/changelog.js @@ -1,4 +1,23 @@ const config = [ + { + title: 'Notifications are finally here!', + shortTitle: 'Notifications', + date: '18/02/2019', + new: [ + 'When you get a notification, you will now be notified by the red flashing Indicator.', + 'When you get a new friend request, you will notified by a sound.', + 'Added a new Recents tab to easily see who messaged you last.', + 'Adjusted the padding and size in some places such as the friends list.', + 'Messages can now be formated (e.g. **Hello**)' + ], + fix: [ + 'Performance improvements were made in some places.', + 'Yesterday is now spelt with a capital "Y" in the timestamp.' + ], + next: [ + 'Uploading images or any files.', + ] + }, { title: 'Typing Indicator', shortTitle: 'Typing Indicator', diff --git a/src/components/app/MessageTemplate.vue b/src/components/app/MessageTemplate.vue index 54d06b1..325c46b 100644 --- a/src/components/app/MessageTemplate.vue +++ b/src/components/app/MessageTemplate.vue @@ -9,7 +9,7 @@
${text.trim()}${text}`
+ })
+ return futoji.format(message);
+}
+
+function escapeHtml(unsafe) {
+ return unsafe
+ .replace(/&/g, "&")
+ .replace(//g, ">")
+ .replace(/"/g, """)
+ .replace(/'/g, "'");
+ }
\ No newline at end of file
diff --git a/src/notificationSound.js b/src/notificationSound.js
new file mode 100644
index 0000000..e845244
--- /dev/null
+++ b/src/notificationSound.js
@@ -0,0 +1,13 @@
+import notificationSound from '@/assets/sounds/Notification.mp3';
+import newFriendSound from '@/assets/sounds/FriendRequest.mp3';
+
+export default {
+ notification: () => {
+ const audio = new Audio(notificationSound);
+ audio.play();
+ },
+ newFriend: () => {
+ const audio = new Audio(newFriendSound);
+ audio.play();
+ }
+}
\ No newline at end of file
diff --git a/src/store/modules/notificationsModule.js b/src/store/modules/notificationsModule.js
index 3ab252a..112a3ec 100644
--- a/src/store/modules/notificationsModule.js
+++ b/src/store/modules/notificationsModule.js
@@ -1,6 +1,7 @@
import {bus} from '../../main'
import {router} from './../../router'
import Vue from 'vue';
+import NotificationSounds from '@/notificationSound';
const state = {
notifications: []
@@ -18,8 +19,13 @@ const actions = {
},
messageCreatedNotification(context, notification) {
const {guildID, channelID, lastMessageID, sender} = notification;
-
-
+ if (!document.hasFocus())
+ bus.$emit('title:change', "Someone sent a message.");
+
+ // dont display a notification if the channel is selected.
+ if (context.rootState.channelModule.selectedChannelID !== channelID || !document.hasFocus()) {
+ NotificationSounds.notification();
+ }
let find = context.state.notifications.find(item => {
return item.channelID === channelID
})
@@ -28,10 +34,22 @@ const actions = {
}
context.commit('messageCreatedNotification', {exists: false, notification: {channelID, lastMessageID, sender, count: 1}});
+ },
+ dismissNotification(context, channelID) {
+ const notifications = context.state.notifications
+ for (let index = 0; index < notifications.length; index++) {
+ if (notifications[index].channelID === channelID){
+ context.commit('dismissNotification', index)
+ break;
+ }
+ }
}
}
const mutations = {
+ dismissNotification(state, index) {
+ Vue.delete(state.notifications, index)
+ },
addAllNotifications(state, notifications){
Vue.set(state, 'notifications', notifications);
},
diff --git a/src/store/modules/socketIOModule.js b/src/store/modules/socketIOModule.js
index 6e4b1bc..e7c0b98 100644
--- a/src/store/modules/socketIOModule.js
+++ b/src/store/modules/socketIOModule.js
@@ -1,5 +1,6 @@
import {bus} from '../../main'
import {router} from './../../router'
+import Vue from 'vue';
const state = {
@@ -64,6 +65,9 @@ const actions = {
tempID: data.tempID
})
}
+ if (context.rootState.channelModule.selectedChannelID == data.message.channelID && document.hasFocus()) {
+ this._vm.$socket.emit('notification:dismiss', {channelID: data.message.channelID});
+ }
// send notification if other users message the recipient
if (data.message.creator.uniqueID === context.getters.user.uniqueID) return;
const notification = {
@@ -92,6 +96,10 @@ const actions = {
const {channel} = data;
// rename to 'channel' to setchannel
context.dispatch('channel', channel);
+ },
+ ['socket_notification:dismiss'](context, data){
+ const {channelID} = data;
+ context.dispatch('dismissNotification', channelID);
}
}
diff --git a/src/store/modules/userModule.js b/src/store/modules/userModule.js
index 16a4c2c..70631f4 100644
--- a/src/store/modules/userModule.js
+++ b/src/store/modules/userModule.js
@@ -2,6 +2,7 @@ import axios from 'axios'
import Vue from 'vue'
import {bus} from '../../main'
import VueRouter from 'vue-router';
+import NotificationSounds from '@/notificationSound';
const state = {
token: localStorage.getItem('hauthid') || null,
@@ -77,6 +78,10 @@ const mutations = {
friends[friend.recipient.uniqueID] = friend;
state.user.friends = Object.assign({}, friends)
+
+ if (friend.status == 1) {
+ NotificationSounds.newFriend();
+ }
},
removeFriend(state, uniqueID) {
const friends = state.user.friends;
diff --git a/src/views/App.vue b/src/views/App.vue
index 773465f..90d5897 100644
--- a/src/views/App.vue
+++ b/src/views/App.vue
@@ -1,6 +1,6 @@