add notifications (?)

This commit is contained in:
hippoz 2020-11-20 22:05:55 +02:00
parent 76e0433753
commit 98cb260ff5

View file

@ -195,6 +195,7 @@ const app = new Vue({
this.showApp = true; this.showApp = true;
this.performGatewayConnection(); this.performGatewayConnection();
this.browseCategories(); this.browseCategories();
Notification.requestPermission();
} else { } else {
this.showApp = false; this.showApp = false;
this.snackbarEditButton('Manage', () => { this.snackbarEditButton('Manage', () => {
@ -239,6 +240,9 @@ const app = new Vue({
} }
if (messageObject.author.username !== this.loggedInUser.username && messageObject.category._id !== this.selection.category._id) { if (messageObject.author.username !== this.loggedInUser.username && messageObject.category._id !== this.selection.category._id) {
if (Notification.permission === 'granted') {
new Notification(`${messageObject.category.title}/${messageObject.author.username}`, messageObject.content);
}
this.okNotification(`${messageObject.category.title}/${messageObject.author.username}: ${messageObject.content}`); this.okNotification(`${messageObject.category.title}/${messageObject.author.username}: ${messageObject.content}`);
} }
}, },
@ -251,7 +255,7 @@ const app = new Vue({
this.selection.category._id = categoryId; this.selection.category._id = categoryId;
}, },
sendCurrentMessage: async function() { sendCurrentMessage: async function() {
const status = this.gateway.sendMessage(this.selection.category._id, this.message.typed); const status = await this.gateway.sendMessage(this.selection.category._id, this.message.typed);
if (status === 1) { if (status === 1) {
this.okNotification('Failed to send message!'); this.okNotification('Failed to send message!');
return; return;