diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2020-11-03 15:59:13 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2020-11-03 15:59:13 +0900 |
| commit | e2a9a0ff3d00800b5910cd57f4551d8c595a059d (patch) | |
| tree | 2ff56ddccbfe851232a8ceba0904c9d07b7ae7be /src/client/ui | |
| parent | Improve performance (diff) | |
| download | misskey-e2a9a0ff3d00800b5910cd57f4551d8c595a059d.tar.gz misskey-e2a9a0ff3d00800b5910cd57f4551d8c595a059d.tar.bz2 misskey-e2a9a0ff3d00800b5910cd57f4551d8c595a059d.zip | |
Refactoring
Diffstat (limited to 'src/client/ui')
| -rw-r--r-- | src/client/ui/_common_/common.vue | 24 | ||||
| -rw-r--r-- | src/client/ui/deck.vue | 23 | ||||
| -rw-r--r-- | src/client/ui/default.vue | 21 | ||||
| -rw-r--r-- | src/client/ui/zen.vue | 21 |
4 files changed, 23 insertions, 66 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, diff --git a/src/client/ui/deck.vue b/src/client/ui/deck.vue index ff1daa58a0..ad65ccd499 100644 --- a/src/client/ui/deck.vue +++ b/src/client/ui/deck.vue @@ -63,7 +63,6 @@ export default defineComponent({ host: host, pageInfo: null, pageKey: 0, - connection: null, menuDef: sidebarDef, wallpaper: localStorage.getItem('wallpaper') != null, faPlus, faPencilAlt, faChevronLeft, faBars, faCircle @@ -107,11 +106,6 @@ export default defineComponent({ document.documentElement.style.overflowY = 'hidden'; document.documentElement.style.scrollBehavior = 'auto'; window.addEventListener('wheel', this.onWheel); - - if (this.$store.getters.isSignedIn) { - this.connection = os.stream.useSharedConnection('main', 'UI'); - this.connection.on('notification', this.onNotification); - } }, mounted() { @@ -143,23 +137,6 @@ export default defineComponent({ os.post(); }, - onNotification(notification) { - if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { - return; - } - - if (document.visibilityState === 'visible') { - os.stream.send('readNotification', { - id: notification.id - }); - - os.popup(import('@/components/toast.vue'), { - notification - }, {}, 'closed'); - } - os.sound('notification'); - }, - async addColumn(ev) { const columns = [ 'widgets', diff --git a/src/client/ui/default.vue b/src/client/ui/default.vue index 2c9d842676..0073a0c8c0 100644 --- a/src/client/ui/default.vue +++ b/src/client/ui/default.vue @@ -91,7 +91,6 @@ export default defineComponent({ host: host, pageKey: 0, pageInfo: null, - connection: null, isDesktop: window.innerWidth >= DESKTOP_THRESHOLD, menuDef: sidebarDef, navHidden: false, @@ -141,9 +140,6 @@ export default defineComponent({ created() { document.documentElement.style.overflowY = 'scroll'; - this.connection = os.stream.useSharedConnection('main', 'UI'); - this.connection.on('notification', this.onNotification); - if (this.$store.state.deviceUser.widgets.length === 0) { this.$store.commit('deviceUser/setWidgets', [{ name: 'calendar', @@ -234,23 +230,6 @@ export default defineComponent({ } }], e); }, - - onNotification(notification) { - if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { - return; - } - if (document.visibilityState === 'visible') { - os.stream.send('readNotification', { - id: notification.id - }); - - os.popup(import('@/components/toast.vue'), { - notification - }, {}, 'closed'); - } - - os.sound('notification'); - }, } }); </script> diff --git a/src/client/ui/zen.vue b/src/client/ui/zen.vue index e3aa077bd7..e76b74d4bf 100644 --- a/src/client/ui/zen.vue +++ b/src/client/ui/zen.vue @@ -42,7 +42,6 @@ export default defineComponent({ host: host, pageKey: 0, pageInfo: null, - connection: null, faLayerGroup, faBars, faBell, faHome, faCircle, }; }, @@ -70,9 +69,6 @@ export default defineComponent({ created() { document.documentElement.style.overflowY = 'scroll'; - - this.connection = os.stream.useSharedConnection('main', 'UI'); - this.connection.on('notification', this.onNotification); }, methods: { @@ -94,23 +90,6 @@ export default defineComponent({ onTransition() { if (window._scroll) window._scroll(); }, - - onNotification(notification) { - if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { - return; - } - if (document.visibilityState === 'visible') { - os.stream.send('readNotification', { - id: notification.id - }); - - os.popup(import('@/components/toast.vue'), { - notification - }, {}, 'closed'); - } - - os.sound('notification'); - }, } }); </script> |