From 98cb260ff5d9d541329adf573883e5245738bd9b Mon Sep 17 00:00:00 2001 From: hippoz Date: Fri, 20 Nov 2020 22:05:55 +0200 Subject: [PATCH] add notifications (?) --- app/resources/js/app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/resources/js/app.js b/app/resources/js/app.js index f7d6b58..ea63c94 100755 --- a/app/resources/js/app.js +++ b/app/resources/js/app.js @@ -195,6 +195,7 @@ const app = new Vue({ this.showApp = true; this.performGatewayConnection(); this.browseCategories(); + Notification.requestPermission(); } else { this.showApp = false; 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 (Notification.permission === 'granted') { + new Notification(`${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; }, 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) { this.okNotification('Failed to send message!'); return;