(draftKey: string)
| 136 | } |
| 137 | |
| 138 | export function loadMessageInputDraft(draftKey: string): string | null { |
| 139 | const cached = draftTextCache.get(draftKey) |
| 140 | if (typeof cached === "string") return cached |
| 141 | if (typeof window === "undefined") return null |
| 142 | |
| 143 | try { |
| 144 | const raw = localStorage.getItem(storageKeyForDraftKey(draftKey)) |
| 145 | if (!raw) return null |
| 146 | const parsed = JSON.parse(raw) as Partial<PersistedDraftState> |
| 147 | if (typeof parsed.text !== "string") return null |
| 148 | draftTextCache.set(draftKey, parsed.text) |
| 149 | return parsed.text |
| 150 | } catch { |
| 151 | return null |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | export function saveMessageInputDraft(draftKey: string, text: string): void { |
| 156 | if (text.length === 0) { |
no test coverage detected