avm99963 | 4c1a679 | 2020-08-31 21:30:42 +0200 | [diff] [blame] | 1 | const defaultOptions = { |
| 2 | 'list': true, |
| 3 | 'thread': true, |
| 4 | 'threadall': false, |
| 5 | 'fixedtoolbar': false, |
| 6 | 'redirect': false, |
| 7 | 'history': false, |
| 8 | 'loaddrafts': false, |
| 9 | 'batchduplicate': false, |
| 10 | 'escalatethreads': false, |
| 11 | 'movethreads': false, |
| 12 | 'increasecontrast': false, |
| 13 | 'stickysidebarheaders': false, |
| 14 | 'profileindicator': false, |
| 15 | }; |
| 16 | |
| 17 | const deprecatedOptions = [ |
| 18 | 'escalatethreads', |
| 19 | 'movethreads', |
| 20 | 'batchduplicate', |
| 21 | ]; |
| 22 | |
| 23 | function isEmpty(obj) { |
| 24 | return Object.keys(obj).length === 0; |
| 25 | } |
| 26 | |
| 27 | function cleanUpOptions(options) { |
| 28 | console.log('[cleanUpOptions] Previous options', options); |
| 29 | var ok = true; |
| 30 | for (const [opt, value] of Object.entries(defaultOptions)) { |
| 31 | if (!(opt in options)) { |
| 32 | ok = false; |
| 33 | options[opt] = value; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | console.log('[cleanUpOptions] New options', options); |
| 38 | |
| 39 | if (!ok) { |
| 40 | chrome.storage.sync.set(options); |
| 41 | } |
| 42 | |
| 43 | return options; |
| 44 | } |