Merge pull request #3176 from bobrippling/fix/improve-formatter-check

Improve boolean formatter check
master
thyttan 2024-02-06 11:09:14 +01:00 committed by GitHub
commit 5a2b5405f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1 additions and 8 deletions

View File

@ -17,7 +17,6 @@
"< Back" : () => back(), "< Back" : () => back(),
'Show Seconds': { 'Show Seconds': {
value: !!settings.showSeconds, // !! converts undefined to false value: !!settings.showSeconds, // !! converts undefined to false
format: v => v ? "On" : "Off",
onchange: v => { onchange: v => {
settings.showSeconds = v; settings.showSeconds = v;
writeSettings(); writeSettings();
@ -25,7 +24,6 @@
}, },
'Invert Scrolling': { 'Invert Scrolling': {
value: !!settings.invertScrolling, // !! converts undefined to false value: !!settings.invertScrolling, // !! converts undefined to false
format: v => v ? "On" : "Off",
onchange: v => { onchange: v => {
settings.invertScrolling = v; settings.invertScrolling = v;
writeSettings(); writeSettings();

View File

@ -20,7 +20,6 @@
"< Back": () => back(), "< Back": () => back(),
'Front Tap:': { 'Front Tap:': {
value: (appSettings.enableTap === true), value: (appSettings.enableTap === true),
format: v => v ? "On" : "Off",
onchange: v => { onchange: v => {
appSettings.enableTap = v; appSettings.enableTap = v;
writeSettings(); writeSettings();

View File

@ -5,7 +5,6 @@
'': { 'title': 'Welcome App' }, '': { 'title': 'Welcome App' },
'Run next boot': { 'Run next boot': {
value: !settings.welcomed, value: !settings.welcomed,
format: v => v ? 'Yes' : 'No',
onchange: v => require('Storage').write('mywelcome.json', {welcomed: !v}), onchange: v => require('Storage').write('mywelcome.json', {welcomed: !v}),
}, },
'Run Now': () => load('mywelcome.app.js'), 'Run Now': () => load('mywelcome.app.js'),

View File

@ -130,7 +130,6 @@
}, },
'Date Suffix:': { 'Date Suffix:': {
value: appSettings.enableSuffix, value: appSettings.enableSuffix,
format: v => v ? 'Yes' : 'No',
onchange: v => { onchange: v => {
appSettings.enableSuffix = v; appSettings.enableSuffix = v;
writeSettings(); writeSettings();
@ -138,7 +137,6 @@
}, },
'Lead Zero:': { 'Lead Zero:': {
value: appSettings.enableLeadingZero, value: appSettings.enableLeadingZero,
format: v => v ? 'Yes' : 'No',
onchange: v => { onchange: v => {
appSettings.enableLeadingZero = v; appSettings.enableLeadingZero = v;
writeSettings(); writeSettings();

View File

@ -5,7 +5,6 @@
'': { 'title': 'Welcome App' }, '': { 'title': 'Welcome App' },
'Run next boot': { 'Run next boot': {
value: !settings.welcomed, value: !settings.welcomed,
format: v => v ? 'Yes' : 'No',
onchange: v => require('Storage').write('welcome.json', {welcomed: !v}), onchange: v => require('Storage').write('welcome.json', {welcomed: !v}),
}, },
'Run Now': () => load('welcome.app.js'), 'Run Now': () => load('welcome.app.js'),

View File

@ -263,7 +263,7 @@ apps.forEach((app,appIdx) => {
WARN(`App ${app.id} has a setting file but no corresponding data entry (add \`"data":[{"name":"${app.id}.settings.json"}]\`)`, {file:appDirRelative+file.url}); WARN(`App ${app.id} has a setting file but no corresponding data entry (add \`"data":[{"name":"${app.id}.settings.json"}]\`)`, {file:appDirRelative+file.url});
} }
// check for manual boolean formatter // check for manual boolean formatter
const m = fileContents.match(/format: *\(\) *=>.*["'](yes|on)["']/i); const m = fileContents.match(/format: *\(?\w*\)? *=>.*["'](yes|on)["']/i);
if (m) { if (m) {
WARN(`Settings for ${app.id} has a boolean formatter - this is handled automatically, the line can be removed`, {file:appDirRelative+file.url, line: fileContents.substr(0, m.index).split("\n").length}); WARN(`Settings for ${app.id} has a boolean formatter - this is handled automatically, the line can be removed`, {file:appDirRelative+file.url, line: fileContents.substr(0, m.index).split("\n").length});
} }