add settings for beta updates [WIP] #173

This commit is contained in:
akashnimare
2017-07-05 03:05:02 +05:30
parent 47cfe86a06
commit 14b9fcf8d7

View File

@@ -21,6 +21,13 @@ class GeneralSection extends BaseComponent {
<div class="setting-control"></div>
</div>
</div>
<div class="title">App updates</div>
<div id="betaupdate-option-settings" class="settings-card">
<div class="setting-row">
<div class="setting-description">Get Beta updates</div>
<div class="setting-control"></div>
</div>
</div>
</div>
`;
}
@@ -41,9 +48,26 @@ class GeneralSection extends BaseComponent {
}
}
updateOptionTemplate(updateOption) {
if (updateOption) {
return `
<div class="action green">
<span>On</span>
</div>
`;
} else {
return `
<div class="action red">
<span>Off</span>
</div>
`;
}
}
init() {
this.props.$root.innerHTML = this.template();
this.initTrayOption();
this.initUpdateOption();
}
initTrayOption() {
@@ -62,6 +86,21 @@ class GeneralSection extends BaseComponent {
});
}
initUpdateOption() {
this.$updateOptionSettings = document.querySelector('#betaupdate-option-settings .setting-control');
this.$updateOptionSettings.innerHTML = '';
const updateOption = ConfigUtil.getConfigItem('BetaUpdate', true);
const $updateOption = this.generateNodeFromTemplate(this.updateOptionTemplate(updateOption));
this.$updateOptionSettings.appendChild($updateOption);
$updateOption.addEventListener('click', () => {
const newValue = !ConfigUtil.getConfigItem('BetaUpdate');
ConfigUtil.setConfigItem('BetaUpdate', newValue);
this.initUpdateOption();
});
}
handleServerInfoChange() {
ipcRenderer.send('reload-main');
}