()
| 14 | } |
| 15 | |
| 16 | const loadSettings = () => { |
| 17 | let settings = {...defaultSettings} |
| 18 | |
| 19 | const cookieValue = getCookie('settings') |
| 20 | |
| 21 | try { |
| 22 | const cookieJSON = JSON.parse(cookieValue) |
| 23 | |
| 24 | if ('baudRate' in cookieJSON) settings.baudRate = cookieJSON.baudRate |
| 25 | } catch (e) { |
| 26 | saveSettings(settings) |
| 27 | console.error(e) |
| 28 | } |
| 29 | |
| 30 | return settings |
| 31 | } |
| 32 | |
| 33 | const saveSettings = (newSettings) => { |
| 34 | setCookie('settings', JSON.stringify(newSettings), 365) |
no test coverage detected