2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2022-01-09 21:35:35 +09:00
|
|
|
<MkPagination ref="pagingComponent" :pagination="pagination">
|
|
|
|
<template #empty>
|
|
|
|
<div class="_fullinfo">
|
|
|
|
<img src="https://xn--931a.moe/assets/info.jpg" class="_ghost"/>
|
|
|
|
<div>{{ $ts.noNotifications }}</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #default="{ items: notifications }">
|
|
|
|
<XList v-slot="{ item: notification }" class="elsfgstc" :items="notifications" :no-gap="true">
|
2022-01-14 10:25:51 +09:00
|
|
|
<XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note"/>
|
2021-11-19 19:36:12 +09:00
|
|
|
<XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/>
|
2021-04-17 00:12:50 +09:00
|
|
|
</XList>
|
2022-01-09 21:35:35 +09:00
|
|
|
</template>
|
|
|
|
</MkPagination>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-09 21:35:35 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineComponent, PropType, markRaw, onUnmounted, onMounted, computed, ref } from 'vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import { notificationTypes } from 'misskey-js';
|
2022-01-09 21:35:35 +09:00
|
|
|
import MkPagination from '@/components/ui/pagination.vue';
|
|
|
|
import { Paging } from '@/components/ui/pagination.vue';
|
|
|
|
import XNotification from '@/components/notification.vue';
|
|
|
|
import XList from '@/components/date-separated-list.vue';
|
|
|
|
import XNote from '@/components/note.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2021-12-29 22:13:09 +09:00
|
|
|
import { stream } from '@/stream';
|
2022-01-09 21:35:35 +09:00
|
|
|
import { $i } from '@/account';
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
includeTypes?: PropType<typeof notificationTypes[number][]>;
|
|
|
|
unreadOnly?: boolean;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const pagingComponent = ref<InstanceType<typeof MkPagination>>();
|
|
|
|
|
|
|
|
const allIncludeTypes = computed(() => props.includeTypes ?? notificationTypes.filter(x => !$i.mutingNotificationTypes.includes(x)));
|
|
|
|
|
|
|
|
const pagination: Paging = {
|
|
|
|
endpoint: 'i/notifications' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
includeTypes: allIncludeTypes.value || undefined,
|
|
|
|
unreadOnly: props.unreadOnly,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
|
|
|
const onNotification = (notification) => {
|
|
|
|
const isMuted = !allIncludeTypes.value.includes(notification.type);
|
|
|
|
if (isMuted || document.visibilityState === 'visible') {
|
|
|
|
stream.send('readNotification', {
|
|
|
|
id: notification.id
|
|
|
|
});
|
|
|
|
}
|
2020-07-29 23:03:08 +09:00
|
|
|
|
2022-01-09 21:35:35 +09:00
|
|
|
if (!isMuted) {
|
|
|
|
pagingComponent.value.prepend({
|
|
|
|
...notification,
|
|
|
|
isRead: document.visibilityState === 'visible'
|
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2022-01-09 21:35:35 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
const connection = stream.useChannel('main');
|
|
|
|
connection.on('notification', onNotification);
|
|
|
|
onUnmounted(() => {
|
|
|
|
connection.dispose();
|
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-08-21 17:40:15 +09:00
|
|
|
.elsfgstc {
|
|
|
|
background: var(--panel);
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
</style>
|