Add check to register state of '0' as false for checkboxes (#2210)

* Add check to register state of '0' as false for checkboxes
* Add comment explaining state === '0'
This commit is contained in:
Alexander Skvortsov 2020-06-28 13:44:14 -04:00 committed by GitHub
parent becc75c5c0
commit 1cfdc23865
2 changed files with 5 additions and 2 deletions

View File

@ -13,8 +13,8 @@ export default class AppearancePage extends Page {
this.primaryColor = m.prop(app.data.settings.theme_primary_color);
this.secondaryColor = m.prop(app.data.settings.theme_secondary_color);
this.darkMode = m.prop(app.data.settings.theme_dark_mode === '1');
this.coloredHeader = m.prop(app.data.settings.theme_colored_header === '1');
this.darkMode = m.prop(app.data.settings.theme_dark_mode);
this.coloredHeader = m.prop(app.data.settings.theme_colored_header);
}
view() {

View File

@ -16,6 +16,9 @@ import icon from '../helpers/icon';
*/
export default class Checkbox extends Component {
view() {
// Sometimes, false is stored in the DB as '0'. This is a temporary
// conversion layer until a more robust settings encoding is introduced
if (this.props.state === '0') this.props.state = false;
let className = 'Checkbox ' + (this.props.state ? 'on' : 'off') + ' ' + (this.props.className || '');
if (this.props.loading) className += ' loading';
if (this.props.disabled) className += ' disabled';