fix: 本地ui优先已读

This commit is contained in:
Tim
2025-08-20 20:55:22 +08:00
parent 22c9bd7d39
commit 99644046fc
3 changed files with 15 additions and 17 deletions

View File

@@ -95,7 +95,6 @@ const closeMilkTeaPopup = () => {
if (!process.client) return if (!process.client) return
localStorage.setItem('milkTeaActivityPopupShown', 'true') localStorage.setItem('milkTeaActivityPopupShown', 'true')
showMilkTeaPopup.value = false showMilkTeaPopup.value = false
checkNotificationSetting()
} }
const checkNotificationSetting = async () => { const checkNotificationSetting = async () => {
@@ -108,7 +107,6 @@ const closeNotificationPopup = () => {
if (!process.client) return if (!process.client) return
localStorage.setItem('notificationSettingPopupShown', 'true') localStorage.setItem('notificationSettingPopupShown', 'true')
showNotificationPopup.value = false showNotificationPopup.value = false
checkNewMedals()
} }
const checkNewMedals = async () => { const checkNewMedals = async () => {
if (!process.client) return if (!process.client) return

View File

@@ -542,7 +542,7 @@ import {
fetchNotifications, fetchNotifications,
fetchUnreadCount, fetchUnreadCount,
isLoadingMessage, isLoadingMessage,
markRead as markNotificationRead, markNotificationRead,
notifications, notifications,
markAllRead, markAllRead,
hasMore, hasMore,
@@ -598,7 +598,7 @@ const togglePref = async (pref) => {
} }
const markRead = async (id) => { const markRead = async (id) => {
await markNotificationRead(id) markNotificationRead(id)
if (selectedTab.value === 'unread') { if (selectedTab.value === 'unread') {
const index = notifications.value.findIndex((n) => n.id === id) const index = notifications.value.findIndex((n) => n.id === id)
if (index !== -1) notifications.value.splice(index, 1) if (index !== -1) notifications.value.splice(index, 1)

View File

@@ -159,7 +159,7 @@ function createFetchNotifications() {
...n, ...n,
src: n.comment.author.avatar, src: n.comment.author.avatar,
iconClick: () => { iconClick: () => {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.comment.author.id}`, { replace: true }) navigateTo(`/users/${n.comment.author.id}`, { replace: true })
}, },
}) })
@@ -169,7 +169,7 @@ function createFetchNotifications() {
emoji: reactionEmojiMap[n.reactionType], emoji: reactionEmojiMap[n.reactionType],
iconClick: () => { iconClick: () => {
if (n.fromUser) { if (n.fromUser) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.fromUser.id}`, { replace: true }) navigateTo(`/users/${n.fromUser.id}`, { replace: true })
} }
}, },
@@ -181,7 +181,7 @@ function createFetchNotifications() {
icon: n.fromUser ? undefined : iconMap[n.type], icon: n.fromUser ? undefined : iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.fromUser) { if (n.fromUser) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.fromUser.id}`, { replace: true }) navigateTo(`/users/${n.fromUser.id}`, { replace: true })
} }
}, },
@@ -193,7 +193,7 @@ function createFetchNotifications() {
icon: n.fromUser ? undefined : iconMap[n.type], icon: n.fromUser ? undefined : iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.fromUser) { if (n.fromUser) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.fromUser.id}`, { replace: true }) navigateTo(`/users/${n.fromUser.id}`, { replace: true })
} }
}, },
@@ -204,7 +204,7 @@ function createFetchNotifications() {
icon: iconMap[n.type], icon: iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.post) { if (n.post) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/posts/${n.post.id}`) navigateTo(`/posts/${n.post.id}`)
} }
}, },
@@ -214,7 +214,7 @@ function createFetchNotifications() {
...n, ...n,
src: n.comment.author.avatar, src: n.comment.author.avatar,
iconClick: () => { iconClick: () => {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.comment.author.id}`, { replace: true }) navigateTo(`/users/${n.comment.author.id}`, { replace: true })
}, },
}) })
@@ -224,7 +224,7 @@ function createFetchNotifications() {
icon: iconMap[n.type], icon: iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.fromUser) { if (n.fromUser) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.fromUser.id}`, { replace: true }) navigateTo(`/users/${n.fromUser.id}`, { replace: true })
} }
}, },
@@ -235,7 +235,7 @@ function createFetchNotifications() {
icon: iconMap[n.type], icon: iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.fromUser) { if (n.fromUser) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/users/${n.fromUser.id}`, { replace: true }) navigateTo(`/users/${n.fromUser.id}`, { replace: true })
} }
}, },
@@ -250,7 +250,7 @@ function createFetchNotifications() {
icon: iconMap[n.type], icon: iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.post) { if (n.post) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/posts/${n.post.id}`, { replace: true }) navigateTo(`/posts/${n.post.id}`, { replace: true })
} }
}, },
@@ -262,7 +262,7 @@ function createFetchNotifications() {
icon: n.fromUser ? undefined : iconMap[n.type], icon: n.fromUser ? undefined : iconMap[n.type],
iconClick: () => { iconClick: () => {
if (n.post) { if (n.post) {
markRead(n.id) markNotificationRead(n.id)
navigateTo(`/posts/${n.post.id}`, { replace: true }) navigateTo(`/posts/${n.post.id}`, { replace: true })
} }
}, },
@@ -290,7 +290,7 @@ function createFetchNotifications() {
} }
} }
const markRead = async (id) => { const markNotificationRead = async (id) => {
if (!id) return if (!id) return
const n = notifications.value.find((n) => n.id === id) const n = notifications.value.find((n) => n.id === id)
if (!n || n.read) return if (!n || n.read) return
@@ -332,7 +332,7 @@ function createFetchNotifications() {
} }
return { return {
fetchNotifications, fetchNotifications,
markRead, markNotificationRead,
notifications, notifications,
isLoadingMessage, isLoadingMessage,
markAllRead, markAllRead,
@@ -342,7 +342,7 @@ function createFetchNotifications() {
export const { export const {
fetchNotifications, fetchNotifications,
markRead, markNotificationRead,
notifications, notifications,
isLoadingMessage, isLoadingMessage,
markAllRead, markAllRead,