32 lines
764 B
TypeScript
32 lines
764 B
TypeScript
import type { TrackedSession } from "./types"
|
|
|
|
export function createTrackedSession(params: {
|
|
sessionId: string
|
|
paneId: string
|
|
description: string
|
|
now?: Date
|
|
}): TrackedSession {
|
|
const now = params.now ?? new Date()
|
|
|
|
return {
|
|
sessionId: params.sessionId,
|
|
paneId: params.paneId,
|
|
description: params.description,
|
|
attachActivated: false,
|
|
attachActivatedAt: undefined,
|
|
createdAt: now,
|
|
lastSeenAt: now,
|
|
closePending: false,
|
|
closeRetryCount: 0,
|
|
activityVersion: 0,
|
|
}
|
|
}
|
|
|
|
export function markTrackedSessionClosePending(tracked: TrackedSession): TrackedSession {
|
|
return {
|
|
...tracked,
|
|
closePending: true,
|
|
closeRetryCount: tracked.closePending ? tracked.closeRetryCount + 1 : tracked.closeRetryCount,
|
|
}
|
|
}
|