Refactoring

This commit is contained in:
syuilo
2020-11-03 15:59:13 +09:00
parent ab166959a4
commit e2a9a0ff3d
4 changed files with 23 additions and 66 deletions

View File

@@ -15,7 +15,8 @@
<script lang="ts">
import { defineAsyncComponent, defineComponent } from 'vue';
import { popups, uploads, pendingApiRequestsCount } from '@/os';
import { stream, sound, popup, popups, uploads, pendingApiRequestsCount } from '@/os';
import { store } from '@/store';
export default defineComponent({
components: {
@@ -24,6 +25,27 @@ export default defineComponent({
},
setup() {
const onNotification = notification => {
if (store.state.i.mutingNotificationTypes.includes(notification.type)) return;
if (document.visibilityState === 'visible') {
stream.send('readNotification', {
id: notification.id
});
popup(import('@/components/toast.vue'), {
notification
}, {}, 'closed');
}
sound('notification');
};
if (store.getters.isSignedIn) {
const connection = stream.useSharedConnection('main', 'UI');
connection.on('notification', onNotification);
}
return {
uploads,
popups,