* Retrieve and consume the stored prompt * @param maxAge - Maximum age of the prompt in milliseconds (default: 24 hours) * @returns The stored prompt or null if not found/expired
(maxAge: number = 24 * 60 * 60 * 1000)
| 197 | * @returns The stored prompt or null if not found/expired |
| 198 | */ |
| 199 | static consume(maxAge: number = 24 * 60 * 60 * 1000): string | null { |
| 200 | const data = BrowserStorage.getItem<{ prompt: string; timestamp: number } | null>( |
| 201 | LandingPromptStorage.KEY, |
| 202 | null |
| 203 | ) |
| 204 | |
| 205 | if (!data || !data.prompt || !data.timestamp) { |
| 206 | return null |
| 207 | } |
| 208 | |
| 209 | const age = Date.now() - data.timestamp |
| 210 | if (age > maxAge) { |
| 211 | LandingPromptStorage.clear() |
| 212 | return null |
| 213 | } |
| 214 | |
| 215 | LandingPromptStorage.clear() |
| 216 | return data.prompt |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Check if there's a stored prompt without consuming it |
no test coverage detected