Skip to content

Commit 509da08

Browse files
committed
Add date to notifications
1 parent e53f741 commit 509da08

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"dependencies": {
1414
"@tauri-apps/api": "^1.2.0",
1515
"@vueuse/core": "^9.12.0",
16+
"dayjs": "^1.11.7",
1617
"pinia": "^2.0.29",
1718
"redaxios": "^0.5.1",
1819
"tauri-plugin-autostart-api": "github:tauri-apps/tauri-plugin-autostart",

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/NotificationList.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts" setup>
2+
import dayjs from 'dayjs'
23
import type { Thread } from '../api/notifications'
34
import type { NotificationListData } from '../types'
45
import { formatReason, notificationSubjectIcon } from '../utils/notification'
@@ -65,6 +66,8 @@ function handleRepoClick() {
6566

6667
<div class="notification-item-content-subtitle">
6768
{{ formatReason(item.reason) }}
69+
-
70+
{{ dayjs(item.updatedAt).fromNow() }}
6871
</div>
6972
</div>
7073
</button>
@@ -130,9 +133,9 @@ function handleRepoClick() {
130133
@include focus-visible;
131134
@include text-outline($size: 1px);
132135
133-
&-read {
134-
color: var(--white-faded) !important;
135-
}
136+
// &-read {
137+
// color: var(--white-faded) !important;
138+
// }
136139
137140
&:hover {
138141
background-color: var(--item-hover-bg)

src/main.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@ import 'focus-visible'
44
import { createApp } from 'vue'
55
import { createPinia } from 'pinia'
66
import { isEnabled as isAutostartEnabled } from 'tauri-plugin-autostart-api'
7+
import dayjs from 'dayjs'
8+
import relativeTime from 'dayjs/plugin/relativeTime'
79
import App from './App.vue'
810
import { AppStorage, cacheStorageFromDisk } from './storage'
911
import { useStore } from './stores/store'
1012
import { Page } from './constants'
1113
import { initDevtools } from './utils/initDevtools'
1214
import { useKey } from './composables/useKey'
1315

14-
window.addEventListener('contextmenu', e => e.preventDefault())
16+
(async () => {
17+
dayjs.extend(relativeTime)
18+
window.addEventListener('contextmenu', e => e.preventDefault())
1519

16-
const app = createApp(App)
17-
const pinia = createPinia()
20+
const app = createApp(App)
21+
const pinia = createPinia()
1822

19-
app.use(pinia)
23+
app.use(pinia)
2024

21-
;(async () => {
2225
await cacheStorageFromDisk()
2326

2427
const store = useStore(pinia)

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface NotificationListDataItem {
1717
title: Thread['subject']['title']
1818
reason: Thread['reason']
1919
type: Thread['subject']['type']
20+
updatedAt: Thread['updated_at']
2021
raw: Raw<Thread>
2122
}
2223

src/utils/notification.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function notificationListItemFromThread(thread: Thread): NotificationListDataIte
2020
title: thread.subject.title,
2121
type: thread.subject.type,
2222
unread: thread.unread,
23+
updatedAt: thread.updated_at,
2324
raw: markRaw(thread),
2425
}
2526
}

0 commit comments

Comments
 (0)