summaryrefslogtreecommitdiff
path: root/src/client/ui/_common_
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-11-03 15:59:13 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-11-03 15:59:13 +0900
commite2a9a0ff3d00800b5910cd57f4551d8c595a059d (patch)
tree2ff56ddccbfe851232a8ceba0904c9d07b7ae7be /src/client/ui/_common_
parentImprove performance (diff)
downloadmisskey-e2a9a0ff3d00800b5910cd57f4551d8c595a059d.tar.gz
misskey-e2a9a0ff3d00800b5910cd57f4551d8c595a059d.tar.bz2
misskey-e2a9a0ff3d00800b5910cd57f4551d8c595a059d.zip
Refactoring
Diffstat (limited to 'src/client/ui/_common_')
-rw-r--r--src/client/ui/_common_/common.vue24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/client/ui/_common_/common.vue b/src/client/ui/_common_/common.vue
index dea3e30a91..d06cbb9869 100644
--- a/src/client/ui/_common_/common.vue
+++ b/src/client/ui/_common_/common.vue
@@ -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,