(store: KeyValueStore, project: string, intent?: WhyIntent)
| 77 | |
| 78 | /** Record the answer, or the decline. Returns what now stands. */ |
| 79 | export function recordWhyAnswer(store: KeyValueStore, project: string, intent?: WhyIntent): WhyAnswer { |
| 80 | const answer: WhyAnswer = intent === undefined ? { asked: true } : { asked: true, intent }; |
| 81 | if (project.length === 0) { |
| 82 | return answer; |
| 83 | } |
| 84 | try { |
| 85 | store.setItem(whyKey(project), JSON.stringify(answer)); |
| 86 | } catch { |
| 87 | // A refused storage costs the reader one repeated question on the next |
| 88 | // load, which is a better failure than a panel that will not close. |
| 89 | } |
| 90 | return answer; |
| 91 | } |
no test coverage detected