mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-25 20:18:05 +09:00
6890e7fca0
* universal.widgets.vue * column.vue, antenna-column.vue * direct-column.vue, list-column.vue * main-column.vue * wip * ✌️ * fix * ✌️ * ✌️
78 lines
2.3 KiB
Vue
78 lines
2.3 KiB
Vue
<template>
|
|
<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">
|
|
<XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note"/>
|
|
<XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/>
|
|
</XList>
|
|
</template>
|
|
</MkPagination>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { defineComponent, markRaw, onUnmounted, onMounted, computed, ref } from 'vue';
|
|
import { notificationTypes } from 'misskey-js';
|
|
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';
|
|
import * as os from '@/os';
|
|
import { stream } from '@/stream';
|
|
import { $i } from '@/account';
|
|
|
|
const props = defineProps<{
|
|
includeTypes?: typeof notificationTypes[number][];
|
|
unreadOnly?: boolean;
|
|
}>();
|
|
|
|
const pagingComponent = ref<InstanceType<typeof MkPagination>>();
|
|
|
|
const pagination: Paging = {
|
|
endpoint: 'i/notifications' as const,
|
|
limit: 10,
|
|
params: computed(() => ({
|
|
includeTypes: props.includeTypes ?? undefined,
|
|
excludeTypes: props.includeTypes ? undefined : $i.mutingNotificationTypes,
|
|
unreadOnly: props.unreadOnly,
|
|
})),
|
|
};
|
|
|
|
const onNotification = (notification) => {
|
|
const isMuted = props.includeTypes ? !props.includeTypes.includes(notification.type) : $i.mutingNotificationTypes.includes(notification.type);
|
|
if (isMuted || document.visibilityState === 'visible') {
|
|
stream.send('readNotification', {
|
|
id: notification.id
|
|
});
|
|
}
|
|
|
|
if (!isMuted) {
|
|
pagingComponent.value.prepend({
|
|
...notification,
|
|
isRead: document.visibilityState === 'visible'
|
|
});
|
|
}
|
|
};
|
|
|
|
onMounted(() => {
|
|
const connection = stream.useChannel('main');
|
|
connection.on('notification', onNotification);
|
|
onUnmounted(() => {
|
|
connection.dispose();
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.elsfgstc {
|
|
background: var(--panel);
|
|
}
|
|
</style>
|