mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(web): handle legacy session summaries (#751)
This commit is contained in:
@@ -42,6 +42,18 @@ describe('classifySessionAttention', () => {
|
||||
expect(attention).toEqual({ kind: 'permission' })
|
||||
})
|
||||
|
||||
it('handles summaries from older APIs without pendingRequestKinds', () => {
|
||||
const legacySummary = makeSummary({ id: 'legacy', updatedAt: 5000 }) as unknown as SessionSummary
|
||||
delete (legacySummary as Partial<SessionSummary>).pendingRequestKinds
|
||||
|
||||
const attention = classifySessionAttention(
|
||||
legacySummary,
|
||||
{ selected: false, lastSeenAt: 1000 }
|
||||
)
|
||||
|
||||
expect(attention).toEqual({ kind: 'unread' })
|
||||
})
|
||||
|
||||
it('shows unread activity when the session has updated since last seen', () => {
|
||||
const attention = classifySessionAttention(
|
||||
makeSummary({ id: 'a', updatedAt: 5000 }),
|
||||
|
||||
@@ -14,15 +14,19 @@ export function classifySessionAttention(
|
||||
return null
|
||||
}
|
||||
|
||||
if (summary.pendingRequestKinds.includes('permission')) {
|
||||
const pendingRequestKinds = Array.isArray(summary.pendingRequestKinds)
|
||||
? summary.pendingRequestKinds
|
||||
: []
|
||||
|
||||
if (pendingRequestKinds.includes('permission')) {
|
||||
return { kind: 'permission' }
|
||||
}
|
||||
|
||||
if (summary.pendingRequestKinds.includes('input')) {
|
||||
if (pendingRequestKinds.includes('input')) {
|
||||
return { kind: 'input' }
|
||||
}
|
||||
|
||||
if (summary.active && summary.backgroundTaskCount > 0) {
|
||||
if (summary.active && (summary.backgroundTaskCount ?? 0) > 0) {
|
||||
return { kind: 'background' }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user