blob: 28c233ac414a2f360f0ec312ee6d19ae0e055d33 [file] [log] [blame]
avm999634c1a6792020-08-31 21:30:42 +02001const 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
17const deprecatedOptions = [
18 'escalatethreads',
19 'movethreads',
20 'batchduplicate',
21];
22
23function isEmpty(obj) {
24 return Object.keys(obj).length === 0;
25}
26
27function 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}