mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-25 04:03:08 +02:00
Refactoring
This commit is contained in:
parent
ab166959a4
commit
e2a9a0ff3d
4 changed files with 23 additions and 66 deletions
|
@ -15,7 +15,8 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineAsyncComponent, defineComponent } from 'vue';
|
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({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
|
@ -24,6 +25,27 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
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 {
|
return {
|
||||||
uploads,
|
uploads,
|
||||||
popups,
|
popups,
|
||||||
|
|
|
@ -63,7 +63,6 @@ export default defineComponent({
|
||||||
host: host,
|
host: host,
|
||||||
pageInfo: null,
|
pageInfo: null,
|
||||||
pageKey: 0,
|
pageKey: 0,
|
||||||
connection: null,
|
|
||||||
menuDef: sidebarDef,
|
menuDef: sidebarDef,
|
||||||
wallpaper: localStorage.getItem('wallpaper') != null,
|
wallpaper: localStorage.getItem('wallpaper') != null,
|
||||||
faPlus, faPencilAlt, faChevronLeft, faBars, faCircle
|
faPlus, faPencilAlt, faChevronLeft, faBars, faCircle
|
||||||
|
@ -107,11 +106,6 @@ export default defineComponent({
|
||||||
document.documentElement.style.overflowY = 'hidden';
|
document.documentElement.style.overflowY = 'hidden';
|
||||||
document.documentElement.style.scrollBehavior = 'auto';
|
document.documentElement.style.scrollBehavior = 'auto';
|
||||||
window.addEventListener('wheel', this.onWheel);
|
window.addEventListener('wheel', this.onWheel);
|
||||||
|
|
||||||
if (this.$store.getters.isSignedIn) {
|
|
||||||
this.connection = os.stream.useSharedConnection('main', 'UI');
|
|
||||||
this.connection.on('notification', this.onNotification);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -143,23 +137,6 @@ export default defineComponent({
|
||||||
os.post();
|
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) {
|
async addColumn(ev) {
|
||||||
const columns = [
|
const columns = [
|
||||||
'widgets',
|
'widgets',
|
||||||
|
|
|
@ -91,7 +91,6 @@ export default defineComponent({
|
||||||
host: host,
|
host: host,
|
||||||
pageKey: 0,
|
pageKey: 0,
|
||||||
pageInfo: null,
|
pageInfo: null,
|
||||||
connection: null,
|
|
||||||
isDesktop: window.innerWidth >= DESKTOP_THRESHOLD,
|
isDesktop: window.innerWidth >= DESKTOP_THRESHOLD,
|
||||||
menuDef: sidebarDef,
|
menuDef: sidebarDef,
|
||||||
navHidden: false,
|
navHidden: false,
|
||||||
|
@ -141,9 +140,6 @@ export default defineComponent({
|
||||||
created() {
|
created() {
|
||||||
document.documentElement.style.overflowY = 'scroll';
|
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) {
|
if (this.$store.state.deviceUser.widgets.length === 0) {
|
||||||
this.$store.commit('deviceUser/setWidgets', [{
|
this.$store.commit('deviceUser/setWidgets', [{
|
||||||
name: 'calendar',
|
name: 'calendar',
|
||||||
|
@ -234,23 +230,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}], e);
|
}], 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>
|
</script>
|
||||||
|
|
|
@ -42,7 +42,6 @@ export default defineComponent({
|
||||||
host: host,
|
host: host,
|
||||||
pageKey: 0,
|
pageKey: 0,
|
||||||
pageInfo: null,
|
pageInfo: null,
|
||||||
connection: null,
|
|
||||||
faLayerGroup, faBars, faBell, faHome, faCircle,
|
faLayerGroup, faBars, faBell, faHome, faCircle,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -70,9 +69,6 @@ export default defineComponent({
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
document.documentElement.style.overflowY = 'scroll';
|
document.documentElement.style.overflowY = 'scroll';
|
||||||
|
|
||||||
this.connection = os.stream.useSharedConnection('main', 'UI');
|
|
||||||
this.connection.on('notification', this.onNotification);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -94,23 +90,6 @@ export default defineComponent({
|
||||||
onTransition() {
|
onTransition() {
|
||||||
if (window._scroll) window._scroll();
|
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>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue