Fix renter settings
This commit is contained in:
@@ -173,7 +173,7 @@
|
||||
<input type="number" id="ID_RenterSetRenewWindow"><br><br>
|
||||
<button id="ID_RenterSettingsDefaults" type="button">Defaults</button>
|
||||
<button id="ID_RenterSettingsOK" type="button">Save</button>
|
||||
<button id="ID_RenterSettingsCancel" type="button">Cancel</button>
|
||||
<button id="ID_RenterSettingsCancel" type="button">Back</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden-element" id="sia_settings_window">
|
||||
|
@@ -282,6 +282,7 @@
|
||||
})();
|
||||
|
||||
let _mountHandler;
|
||||
let _allowRenterSave = true;
|
||||
|
||||
function setMainWindow(name) {
|
||||
console.log('Setting main window: ' + name);
|
||||
@@ -432,7 +433,6 @@
|
||||
}
|
||||
|
||||
function handleRenterEditSettings() {
|
||||
setMainWindow('renter_settings_window');
|
||||
const funds = document.getElementById('ID_RenterSetFunds');
|
||||
funds.oninput = () => {
|
||||
AppActions.calculateEstimatedStorage(funds.value, (res) => {
|
||||
@@ -441,18 +441,9 @@
|
||||
};
|
||||
|
||||
const defaultsButton = document.getElementById('ID_RenterSettingsDefaults');
|
||||
defaultsButton.onclick = () => {
|
||||
funds.oninput = null;
|
||||
const settings = UiState.defaultRenterSettings();
|
||||
if (getValue('ID_RenterSetFunds') === '0') {
|
||||
setValue('ID_RenterSetFunds', settings.Funds);
|
||||
}
|
||||
setValue('ID_RenterSetHosts', settings.Hosts);
|
||||
setValue('ID_RenterSetPeriod', settings.Period);
|
||||
setValue('ID_RenterSetRenewWindow', settings.RenewWindowInBlocks);
|
||||
};
|
||||
|
||||
const cancelButton = document.getElementById('ID_RenterSettingsCancel');
|
||||
const saveButton = document.getElementById('ID_RenterSettingsOK');
|
||||
|
||||
cancelButton.onclick = () => {
|
||||
funds.oninput = null;
|
||||
saveButton.onclick = null;
|
||||
@@ -461,26 +452,46 @@
|
||||
beginMainApplication(false);
|
||||
};
|
||||
|
||||
const saveButton = document.getElementById('ID_RenterSettingsOK');
|
||||
saveButton.onclick = () => {
|
||||
funds.oninput = null;
|
||||
saveButton.onclick = null;
|
||||
cancelButton.onclick = null;
|
||||
defaultsButton.onclick = null;
|
||||
AppActions.setRenterSettings({
|
||||
'Funds': getValue('ID_RenterSetFunds'),
|
||||
'Hosts': getValue('ID_RenterSetHosts'),
|
||||
'Period': getValue('ID_RenterSetPeriod'),
|
||||
'RenewWindowInBlocks': getValue('ID_RenterSetRenewWindow')
|
||||
}, (success, reason) => {
|
||||
if (success) {
|
||||
beginMainApplication(false);
|
||||
} else {
|
||||
displayErrorPopup('Allocation Failed', reason);
|
||||
handleRenterEditSettings();
|
||||
if (_allowRenterSave) {
|
||||
defaultsButton.classList.remove('hidden-element');
|
||||
saveButton.classList.remove('hidden-element');
|
||||
defaultsButton.onclick = () => {
|
||||
funds.oninput = null;
|
||||
const settings = UiState.defaultRenterSettings();
|
||||
if (getValue('ID_RenterSetFunds') === '0') {
|
||||
setValue('ID_RenterSetFunds', settings.Funds);
|
||||
}
|
||||
});
|
||||
};
|
||||
setValue('ID_RenterSetHosts', settings.Hosts);
|
||||
setValue('ID_RenterSetPeriod', settings.Period);
|
||||
setValue('ID_RenterSetRenewWindow', settings.RenewWindowInBlocks);
|
||||
};
|
||||
|
||||
saveButton.onclick = () => {
|
||||
_allowRenterSave = false;
|
||||
funds.oninput = null;
|
||||
saveButton.onclick = null;
|
||||
cancelButton.onclick = null;
|
||||
defaultsButton.onclick = null;
|
||||
AppActions.setRenterSettings({
|
||||
'Funds': getValue('ID_RenterSetFunds'),
|
||||
'Hosts': getValue('ID_RenterSetHosts'),
|
||||
'Period': getValue('ID_RenterSetPeriod'),
|
||||
'RenewWindowInBlocks': getValue('ID_RenterSetRenewWindow')
|
||||
}, (success, reason) => {
|
||||
if (!success) {
|
||||
displayErrorPopup('Allocation Failed', reason);
|
||||
}
|
||||
_allowRenterSave = true;
|
||||
});
|
||||
|
||||
beginMainApplication(false);
|
||||
};
|
||||
} else {
|
||||
defaultsButton.classList.add('hidden-element');
|
||||
saveButton.classList.add('hidden-element');
|
||||
}
|
||||
|
||||
setMainWindow('renter_settings_window');
|
||||
}
|
||||
|
||||
function manualUnlockWallet() {
|
||||
|
Reference in New Issue
Block a user