Symptom
Tapping "mark as read" in notifications clears the badge, then it comes straight
back to the same count (3 in the reported case). It only really clears after
restarting the app.
Root cause
lib/notifications-context.tsx:43-55 clears the badge locally and re-queries the
chain one second later:
const onNotificationsMarkedAsRead = useCallback(() => {
setBadgeCount(0);
// …
markedAsReadTimerRef.current = setTimeout(() => {
updateBadgeCount();
}, 1000); // Wait 1 second for the mark as read operation to complete on blockchain
}, [updateBadgeCount]);
The comment states the intent, and the number is the bug. markAsRead broadcasts a
transaction; Hive produces a block roughly every 3 seconds, so after 1s the
transaction is typically not in a block yet. fetchNewNotifications then reads the
pre-mark state and returns the same notifications, so setBadgeCount puts the count
back.
Restarting works because by then the chain has caught up.
components/notifications/NotificationsScreen.tsx:33-35 does await markAsRead()
before signalling, but a broadcast resolving is not the same as the transaction
being included and the node reflecting it.
Suggested fix
Simplest is to drop the eager re-query. The local setBadgeCount(0) is already
correct, and the existing 2-minute refresh (notifications-context.tsx:63-71)
reconciles on its own.
Bumping the delay to ~5s would also work but stays a race against block time and
node propagation.
Suggested label: bug, mobile
Symptom
Tapping "mark as read" in notifications clears the badge, then it comes straight
back to the same count (3 in the reported case). It only really clears after
restarting the app.
Root cause
lib/notifications-context.tsx:43-55clears the badge locally and re-queries thechain one second later:
The comment states the intent, and the number is the bug.
markAsReadbroadcasts atransaction; Hive produces a block roughly every 3 seconds, so after 1s the
transaction is typically not in a block yet.
fetchNewNotificationsthen reads thepre-mark state and returns the same notifications, so
setBadgeCountputs the countback.
Restarting works because by then the chain has caught up.
components/notifications/NotificationsScreen.tsx:33-35does awaitmarkAsRead()before signalling, but a broadcast resolving is not the same as the transaction
being included and the node reflecting it.
Suggested fix
Simplest is to drop the eager re-query. The local
setBadgeCount(0)is alreadycorrect, and the existing 2-minute refresh (
notifications-context.tsx:63-71)reconciles on its own.
Bumping the delay to ~5s would also work but stays a race against block time and
node propagation.
Suggested label:
bug,mobile