feat: opening the notifications inbox marks what it shows as read (#6275)
release / govulncheck (push) Successful in 22s
release / web (push) Successful in 1m23s
release / go (push) Successful in 1m39s
release / android (push) Failing after 4m25s
release / integration (push) Successful in 5m8s
release / Build signed APK (releases and dev) (push) Successful in 5m33s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
release / govulncheck (push) Successful in 22s
release / web (push) Successful in 1m23s
release / go (push) Successful in 1m39s
release / android (push) Failing after 4m25s
release / integration (push) Successful in 5m8s
release / Build signed APK (releases and dev) (push) Successful in 5m33s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
The web panel and the Android Notifications screen now mark every unread notice they show as read the moment they appear, so the badge clears on a look instead of a dismissal. Rows that were unread keep looking new until the inbox closes. The read goes through read-all with a cutoff of the newest notice shown plus 1 ms, so one that arrived unseen stays unread. 'Mark all read' is gone; opening the inbox does its job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,8 +44,19 @@ export async function markNotificationRead(id: string): Promise<void> {
|
||||
await api.post(`/api/me/notifications/${encodeURIComponent(id)}/read`, {});
|
||||
}
|
||||
|
||||
export async function markAllNotificationsRead(): Promise<void> {
|
||||
await api.post('/api/me/notifications/read-all', {});
|
||||
/** upTo limits it to notices created at or before then, so one the inbox never showed stays unread. */
|
||||
export async function markAllNotificationsRead(upTo?: string): Promise<void> {
|
||||
await api.post('/api/me/notifications/read-all', upTo ? { up_to: upTo } : {});
|
||||
}
|
||||
|
||||
/**
|
||||
* The read-all cutoff for what the inbox shows: the newest notice, plus a
|
||||
* millisecond. The server keeps microseconds and Date only milliseconds, so
|
||||
* without the rounding up the newest notice would stay unread.
|
||||
*/
|
||||
export function readAllCutoff(items: NotificationItem[]): string | undefined {
|
||||
const newest = Math.max(...items.map((i) => Date.parse(i.created_at)).filter((t) => !Number.isNaN(t)));
|
||||
return Number.isFinite(newest) ? new Date(newest + 1).toISOString() : undefined;
|
||||
}
|
||||
|
||||
export function createNotificationsQuery() {
|
||||
|
||||
Reference in New Issue
Block a user