forked from FoundKeyGang/FoundKey
client: pass along notifications if push notifs disabled
This commit is contained in:
parent
23953b9ad1
commit
cd87e262fe
1 changed files with 6 additions and 7 deletions
|
@ -19,6 +19,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineAsyncComponent, Ref, ref } from 'vue';
|
import { defineAsyncComponent, Ref, ref } from 'vue';
|
||||||
import { swInject } from './sw-inject';
|
import { swInject } from './sw-inject';
|
||||||
|
import { instance } from '@/instance';
|
||||||
import { popup as showPopup, popups, pendingApiRequestsCount } from '@/os';
|
import { popup as showPopup, popups, pendingApiRequestsCount } from '@/os';
|
||||||
import { uploads } from '@/scripts/upload';
|
import { uploads } from '@/scripts/upload';
|
||||||
import * as sound from '@/scripts/sound';
|
import * as sound from '@/scripts/sound';
|
||||||
|
@ -32,14 +33,12 @@ const dev: Ref<boolean> = ref(_DEV_);
|
||||||
const onNotification = (notification: { type: string; id: any; }): void => {
|
const onNotification = (notification: { type: string; id: any; }): void => {
|
||||||
if ($i?.mutingNotificationTypes.includes(notification.type)) return;
|
if ($i?.mutingNotificationTypes.includes(notification.type)) return;
|
||||||
|
|
||||||
if (document.visibilityState === 'visible') {
|
// if push notifications are enabled there is no need to pass the notification along
|
||||||
stream.send('readNotification', {
|
if (!instance.enableServiceWorker) {
|
||||||
id: notification.id,
|
// service worker is not enabled or set up on the server, pass the notification along
|
||||||
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
|
registration.active.postMessage({ type: 'notification', body: notification });
|
||||||
});
|
});
|
||||||
|
|
||||||
showPopup(defineAsyncComponent(() => import('@/components/notification-toast.vue')), {
|
|
||||||
notification,
|
|
||||||
}, {}, 'closed');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sound.play('notification');
|
sound.play('notification');
|
||||||
|
|
Loading…
Reference in a new issue