Web notification improvements
This commit is contained in:
parent
7ed3e80b9c
commit
13ef686e36
4 changed files with 61 additions and 46 deletions
|
|
@ -346,7 +346,7 @@
|
|||
depressed
|
||||
block
|
||||
class="filled-button"
|
||||
@click.stop="onRequestNotificationAndServiceWorker"
|
||||
@click.stop="onNotifyRequest"
|
||||
>{{ $t("notification.dialog.enable") }}</v-btn
|
||||
>
|
||||
</v-col>
|
||||
|
|
@ -379,8 +379,7 @@ import chatMixin from "./chatMixin";
|
|||
import sendAttachmentsMixin from "./sendAttachmentsMixin";
|
||||
import AudioLayout from "./AudioLayout.vue";
|
||||
import FileDropLayout from "./file_mode/FileDropLayout";
|
||||
import { requestNotificationAndServiceWorker, windowNotificationPermission, notificationCount } from "../plugins/notificationAndServiceWorker.js"
|
||||
import logoMixin from "./logoMixin";
|
||||
import { requestNotificationPermission, windowNotificationPermission } from "../plugins/notificationAndServiceWorker.js"
|
||||
import roomTypeMixin from "./roomTypeMixin";
|
||||
import roomMembersMixin from "./roomMembersMixin";
|
||||
|
||||
|
|
@ -418,7 +417,7 @@ ScrollPosition.prototype.prepareFor = function (direction) {
|
|||
|
||||
export default {
|
||||
name: "Chat",
|
||||
mixins: [chatMixin, logoMixin, roomTypeMixin, sendAttachmentsMixin, roomMembersMixin],
|
||||
mixins: [chatMixin, roomTypeMixin, sendAttachmentsMixin, roomMembersMixin],
|
||||
components: {
|
||||
ChatHeader,
|
||||
ChatHeaderPrivate,
|
||||
|
|
@ -554,7 +553,6 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
notificationCount,
|
||||
nonImageFiles() {
|
||||
return this.isCurrentFileInputsAnArray && this.currentFileInputs.filter(file => !file?.type.includes("image/"))
|
||||
},
|
||||
|
|
@ -742,13 +740,6 @@ export default {
|
|||
},
|
||||
|
||||
watch: {
|
||||
notificationCount: {
|
||||
handler(nCount) {
|
||||
if (nCount > 0 && this.windowNotificationPermission() === "granted") {
|
||||
this.showNotification()
|
||||
}
|
||||
}
|
||||
},
|
||||
initialLoadDone: {
|
||||
immediate: true,
|
||||
handler(value, oldValue) {
|
||||
|
|
@ -841,22 +832,6 @@ export default {
|
|||
|
||||
methods: {
|
||||
windowNotificationPermission,
|
||||
showNotification() {
|
||||
if(document.visibilityState === "visible") {
|
||||
return;
|
||||
}
|
||||
|
||||
const title = this.$t('notification.title');
|
||||
const self = this;
|
||||
|
||||
navigator.serviceWorker.ready.then(function(registration) {
|
||||
registration.showNotification(title, {
|
||||
icon: self.logotype,
|
||||
tag: "new-message-notification",
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
onNotificationDialog() {
|
||||
if(this.windowNotificationPermission() === 'denied') {
|
||||
alert(this.$t("notification.blocked_message"));
|
||||
|
|
@ -864,8 +839,8 @@ export default {
|
|||
this.notificationDialog = true;
|
||||
}
|
||||
},
|
||||
onRequestNotificationAndServiceWorker() {
|
||||
requestNotificationAndServiceWorker()
|
||||
onNotifyRequest() {
|
||||
requestNotificationPermission()
|
||||
this.notificationDialog = false;
|
||||
},
|
||||
onRoomJoined(initialEventId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue