(notice: Notice)
| 211 | // expiry can't wipe this one. A 'ttl' notice with `ttl_ms` self-expires; |
| 212 | // 'sticky' (default) persists until an explicit clear. |
| 213 | private applyNotice(notice: Notice) { |
| 214 | this.clearNoticeTimer() |
| 215 | patchUiState({ notice }) |
| 216 | |
| 217 | if (notice.kind === 'ttl' && typeof notice.ttl_ms === 'number' && notice.ttl_ms > 0) { |
| 218 | const id = notice.id |
| 219 | |
| 220 | this.noticeTimer = setTimeout(() => { |
| 221 | this.noticeTimer = null |
| 222 | |
| 223 | // Defensive backup: the prior timer was already cancelled by |
| 224 | // clearNoticeTimer() when a newer notice was applied, so in |
| 225 | // practice this guard only fires for the notice that armed it. |
| 226 | if (getUiState().notice?.id === id) { |
| 227 | patchUiState({ notice: null }) |
| 228 | } |
| 229 | }, notice.ttl_ms) |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | private clearNoticeTimer() { |
| 234 | this.noticeTimer = clear(this.noticeTimer) |
no test coverage detected