11<script lang="ts" setup>
22import dayjs from ' dayjs'
3- import type { Thread } from ' ../api/notifications'
4- import type { NotificationListData } from ' ../types'
5- import { formatReason , notificationSubjectIcon } from ' ../utils/notification'
3+ import { MinimalRepository , Thread } from ' ../api/notifications'
4+ import type { NotificationList } from ' ../types'
5+ import { formatReason , isRepository , notificationSubjectIcon } from ' ../utils/notification'
66import Separator from ' ./Separator.vue'
77
88interface Emits {
@@ -11,74 +11,74 @@ interface Emits {
1111}
1212
1313interface Props {
14- data : NotificationListData
14+ value : NotificationList [ number ]
1515}
1616
1717const props = defineProps <Props >()
1818const emit = defineEmits <Emits >()
1919
20- function handleNotificationClick( notification : Thread ) {
21- emit (' click:notification' , notification )
20+ function handleThreadClick( thread : Thread ) {
21+ emit (' click:notification' , thread )
2222}
2323
24- function handleRepoClick() {
25- emit (' click:repo' , props . data . repoFullName )
24+ function handleRepoClick(repo : MinimalRepository ) {
25+ emit (' click:repo' , repo . full_name )
2626}
2727 </script >
2828
2929<template >
3030 <div
31- draggable = " false "
32- class =" notification"
31+ v-if = " isRepository(value) "
32+ class =" notification-title-wrapper "
3333 >
3434 <button
3535 class =" notification-title"
36- @click =" handleRepoClick"
36+ @click =" handleRepoClick(value as MinimalRepository) "
3737 >
3838 <img
3939 class =" notification-title-icon"
40- :src =" props.data.repoAvatarURL "
40+ :src =" (value as MinimalRepository).owner.avatar_url "
4141 alt =" repo logo"
4242 >
4343 <span class =" notification-title-text" >
44- {{ props.data.repoFullName }}
44+ {{ (value as MinimalRepository).full_name }}
4545 </span >
4646 </button >
4747
4848 <Separator />
49+ </div >
4950
50- <button
51- v-for =" item of props.data.items"
52- :key =" item.id"
53- class =" notification-item"
54- :class =" { 'notification-item-read': !item.unread }"
55- @click =" handleNotificationClick(item.raw)"
56- >
57- <Component
58- :is =" notificationSubjectIcon(item.type)"
59- class =" notification-item-icon"
60- />
61-
62- <div class =" notification-item-content" >
63- <div class =" notification-item-content-title" >
64- {{ item.title }}
65- </div >
66-
67- <div class =" notification-item-content-subtitle" >
68- {{ formatReason(item.reason) }}
69- -
70- {{ dayjs(item.updatedAt).fromNow() }}
71- </div >
51+ <button
52+ v-else
53+ class =" notification-item"
54+ :class =" { 'notification-item-read': !(value as Thread).unread }"
55+ @click =" handleThreadClick(value as Thread)"
56+ >
57+ <Component
58+ :is =" notificationSubjectIcon((value as Thread).subject.type)"
59+ class =" notification-item-icon"
60+ />
61+
62+ <div class =" notification-item-content" >
63+ <div class =" notification-item-content-title" >
64+ {{ (value as Thread).subject.title }}
7265 </div >
73- </button >
74- </div >
66+
67+ <div class =" notification-item-content-subtitle" >
68+ {{ formatReason((value as Thread).reason) }}
69+ -
70+ {{ dayjs((value as Thread).updated_at).fromNow() }}
71+ </div >
72+ </div >
73+ </button >
7574</template >
7675
7776<style lang="scss" scoped>
77+ * + .notification-title-wrapper {
78+ margin-top : 10px
79+ }
80+
7881.notification {
79- + .notification {
80- margin-top : 10px ;
81- }
8282
8383 & -title {
8484 @include focus-visible ;
@@ -132,6 +132,7 @@ function handleRepoClick() {
132132 line-height : 20px ;
133133 @include focus-visible ;
134134 @include text-outline ($size : 1px );
135+ margin-top : 5px ;
135136
136137 & -read {
137138 color : var (--white-faded ) !important ;
0 commit comments