fix: attempt to resolve notification indicator issue
This commit is contained in:
parent
5c39413420
commit
2e4602e973
2 changed files with 12 additions and 3 deletions
|
|
@ -130,6 +130,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
|
||||||
setProfileEvent(null)
|
setProfileEvent(null)
|
||||||
setNsec(null)
|
setNsec(null)
|
||||||
setFavoriteRelaysEvent(null)
|
setFavoriteRelaysEvent(null)
|
||||||
|
setNotificationsSeenAt(-1)
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +148,12 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
|
||||||
} else {
|
} else {
|
||||||
setNcryptsec(null)
|
setNcryptsec(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const storedNotificationsSeenAt = storage.getLastReadNotificationTime(account.pubkey)
|
||||||
|
if (storedNotificationsSeenAt) {
|
||||||
|
setNotificationsSeenAt(storedNotificationsSeenAt)
|
||||||
|
}
|
||||||
|
|
||||||
const [
|
const [
|
||||||
storedRelayListEvent,
|
storedRelayListEvent,
|
||||||
storedProfileEvent,
|
storedProfileEvent,
|
||||||
|
|
@ -251,15 +258,12 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
|
||||||
await indexedDb.putReplaceableEvent(favoriteRelaysEvent)
|
await indexedDb.putReplaceableEvent(favoriteRelaysEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
const storedNotificationsSeenAt = storage.getLastReadNotificationTime(account.pubkey)
|
|
||||||
if (
|
if (
|
||||||
notificationsSeenAtEvent &&
|
notificationsSeenAtEvent &&
|
||||||
notificationsSeenAtEvent.created_at > storedNotificationsSeenAt
|
notificationsSeenAtEvent.created_at > storedNotificationsSeenAt
|
||||||
) {
|
) {
|
||||||
setNotificationsSeenAt(notificationsSeenAtEvent.created_at)
|
setNotificationsSeenAt(notificationsSeenAtEvent.created_at)
|
||||||
storage.setLastReadNotificationTime(account.pubkey, notificationsSeenAtEvent.created_at)
|
storage.setLastReadNotificationTime(account.pubkey, notificationsSeenAtEvent.created_at)
|
||||||
} else {
|
|
||||||
setNotificationsSeenAt(storedNotificationsSeenAt)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.initUserIndexFromFollowings(account.pubkey, controller.signal)
|
client.initUserIndexFromFollowings(account.pubkey, controller.signal)
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,11 @@ export function NotificationProvider({ children }: { children: React.ReactNode }
|
||||||
const clearNewNotifications = async () => {
|
const clearNewNotifications = async () => {
|
||||||
if (!pubkey) return
|
if (!pubkey) return
|
||||||
|
|
||||||
|
if (subCloserRef.current) {
|
||||||
|
subCloserRef.current.close()
|
||||||
|
subCloserRef.current = null
|
||||||
|
}
|
||||||
|
|
||||||
setNewNotificationIds(new Set())
|
setNewNotificationIds(new Set())
|
||||||
await updateNotificationsSeenAt()
|
await updateNotificationsSeenAt()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue