Added a system for tracking mobile search attempts and updated associated tests

This commit is contained in:
2025-11-03 15:34:34 +01:00
parent 2cc9df5278
commit 105bbd1f8a
6 changed files with 110 additions and 16 deletions

View File

@@ -0,0 +1,26 @@
export class MobileRetryTracker {
private attempts = 0
private readonly maxRetries: number
constructor(maxRetries: number) {
const normalized = Number.isFinite(maxRetries) ? Math.floor(maxRetries) : 0
this.maxRetries = Math.max(0, normalized)
}
/**
* Register an incomplete mobile search attempt.
* @returns true when another retry should be attempted, false when the retry budget is exhausted.
*/
registerFailure(): boolean {
this.attempts += 1
return this.attempts <= this.maxRetries
}
hasExceeded(): boolean {
return this.attempts > this.maxRetries
}
getAttemptCount(): number {
return this.attempts
}
}