2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
|
|
|
<component v-for="popup in popups"
|
|
|
|
:key="popup.id"
|
|
|
|
:is="popup.component"
|
|
|
|
v-bind="popup.props"
|
|
|
|
v-on="popup.events"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<XUpload v-if="uploads.length > 0"/>
|
|
|
|
|
2020-10-24 18:21:41 +02:00
|
|
|
<XStreamIndicator/>
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<div id="wait" v-if="pendingApiRequestsCount > 0"></div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineAsyncComponent, defineComponent } from 'vue';
|
2020-11-25 13:31:34 +01:00
|
|
|
import { stream, popup, popups, uploads, pendingApiRequestsCount } from '@/os';
|
|
|
|
import * as sound from '@/scripts/sound';
|
2020-12-19 02:55:52 +01:00
|
|
|
import { $i, $i } from '@/account';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-10-24 18:21:41 +02:00
|
|
|
XStreamIndicator: defineAsyncComponent(() => import('./stream-indicator.vue')),
|
|
|
|
XUpload: defineAsyncComponent(() => import('./upload.vue')),
|
2020-10-17 13:12:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
setup() {
|
2020-11-03 07:59:13 +01:00
|
|
|
const onNotification = notification => {
|
2020-12-19 02:55:52 +01:00
|
|
|
if ($i.mutingNotificationTypes.includes(notification.type)) return;
|
2020-11-03 07:59:13 +01:00
|
|
|
|
|
|
|
if (document.visibilityState === 'visible') {
|
|
|
|
stream.send('readNotification', {
|
|
|
|
id: notification.id
|
|
|
|
});
|
|
|
|
|
|
|
|
popup(import('@/components/toast.vue'), {
|
|
|
|
notification
|
|
|
|
}, {}, 'closed');
|
|
|
|
}
|
|
|
|
|
2020-11-25 13:31:34 +01:00
|
|
|
sound.play('notification');
|
2020-11-03 07:59:13 +01:00
|
|
|
};
|
|
|
|
|
2020-12-19 02:55:52 +01:00
|
|
|
if ($i) {
|
2020-11-03 07:59:13 +01:00
|
|
|
const connection = stream.useSharedConnection('main', 'UI');
|
|
|
|
connection.on('notification', onNotification);
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
return {
|
|
|
|
uploads,
|
|
|
|
popups,
|
|
|
|
pendingApiRequestsCount,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
#wait {
|
|
|
|
display: block;
|
|
|
|
position: fixed;
|
|
|
|
z-index: 10000;
|
|
|
|
top: 15px;
|
|
|
|
right: 15px;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
width: 18px;
|
|
|
|
height: 18px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: solid 2px transparent;
|
|
|
|
border-top-color: var(--accent);
|
|
|
|
border-left-color: var(--accent);
|
|
|
|
border-radius: 50%;
|
|
|
|
animation: progress-spinner 400ms linear infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes progress-spinner {
|
|
|
|
0% {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
transform: rotate(360deg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|