Repository navigation
fix(notifications): stop clearing phone alerts that were never sent #37095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,15 +121,19 @@ export class MobileNotificationDismissalStore { | |
| return this.flush() | ||
| } | ||
|
|
||
| /** Unreadable history cannot rule a delivery out. */ | ||
| hasLiveDelivery(notificationId: string): boolean { | ||
| const now = Date.now() | ||
| return ( | ||
| this.unreadable || | ||
| this.entries.some((entry) => entry.notificationId === notificationId && isLive(entry, now)) | ||
| ) | ||
| } | ||
|
|
||
| liveDeliveries(prefix = ''): DeliveredNotificationRecord[] { | ||
| const now = Date.now() | ||
| return this.entries | ||
| .filter( | ||
| (entry) => | ||
| entry.expiresAt > now && | ||
| entry.notificationId.startsWith(prefix) && | ||
| entry.dismissedThrough < entry.notificationSeq | ||
| ) | ||
| .filter((entry) => entry.notificationId.startsWith(prefix) && isLive(entry, now)) | ||
| .map(({ notificationId, notificationEpoch, notificationSeq, structuredOrigin }) => ({ | ||
| notificationId, | ||
| notificationEpoch, | ||
|
|
@@ -153,6 +157,10 @@ export class MobileNotificationDismissalStore { | |
| } | ||
| } | ||
|
|
||
| function isLive(entry: RecordEntry, now: number): boolean { | ||
| return entry.expiresAt > now && entry.dismissedThrough < entry.notificationSeq | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not expire undismissed deliveries after seven days. A phone can still show an alert after its store entry expires. A desktop read then skips its clear, even when the entry was not evicted. Keep undismissed entries until they are retired or reach the accepted capacity limit. Also update the pruning in |
||
| } | ||
|
|
||
| /** Keep records with unknown future origin kinds, degrading only their origin to none. */ | ||
| function readEntry(value: unknown): RecordEntry[] { | ||
| if (!isEntry(value)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Treat malformed history as uncertain.
If the saved JSON is malformed,
JSON.parsethrows, butisUnreadableErrorreturns false for the parse error. The store then reports no live deliveries and suppresses clears for pre-restart alerts. Treat an invalid snapshot as unknown history and forward those clears. (raw.githubusercontent.com)