feat: 💨

This commit is contained in:
codytseng
2025-07-27 22:21:19 +08:00
parent 4286551b12
commit 5baa0b0ce3
2 changed files with 14 additions and 22 deletions

View File

@@ -72,7 +72,7 @@ type TNostrContext = {
const NostrContext = createContext<TNostrContext | undefined>(undefined)
let lastPublishedSeenNotificationsAtEventAt = -1
const lastPublishedSeenNotificationsAtEventAtMap = new Map<string, number>()
export const useNostr = () => {
const context = useContext(NostrContext)
@@ -691,12 +691,14 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
}, 5_000)
// Prevent too frequent requests for signing seen notifications events
const lastPublishedSeenNotificationsAtEventAt =
lastPublishedSeenNotificationsAtEventAtMap.get(account.pubkey) ?? -1
if (
lastPublishedSeenNotificationsAtEventAt < 0 ||
now - lastPublishedSeenNotificationsAtEventAt > 10 * 60 // 10 minutes
) {
await publish(createSeenNotificationsAtDraftEvent())
lastPublishedSeenNotificationsAtEventAt = now
lastPublishedSeenNotificationsAtEventAtMap.set(account.pubkey, now)
}
}