mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Changed approach of setting connection timeout by introducing a slider and handle the conversion between seconds and milliseconds during options processing
This commit is contained in:
parent
0b63edb8f8
commit
a7ef451f4c
6 changed files with 19 additions and 18 deletions
|
|
@ -1023,11 +1023,11 @@
|
|||
"description": "Clear credentials timeout help text."
|
||||
},
|
||||
"optionsConnectionTimeout": {
|
||||
"message": "KeepassXC connection timeout (seconds, 2-60).",
|
||||
"message": "KeepassXC connection timeout: $1 seconds",
|
||||
"description": "Connection timeout label text."
|
||||
},
|
||||
"optionsConnectionTimeoutHelpText": {
|
||||
"message": "When KeePassXC browser extension tries to connect to to keepass, this timeout value is used",
|
||||
"message": "When KeePassXC browser extension tries to connect to to keepass, this timeout value is used. Default value is 1.5. Maximum is 60.0.",
|
||||
"description": "Connection timeout label text."
|
||||
},
|
||||
"optionsVersionInfoText": {
|
||||
|
|
|
|||
|
|
@ -804,11 +804,7 @@ keepass.disableAutomaticReconnect = function() {
|
|||
keepass.reconnectLoop = null;
|
||||
};
|
||||
|
||||
keepass.reconnect = async function(tab = null, connectionTimeout = -1) {
|
||||
if (connectionTimeout === -1) {
|
||||
connectionTimeout = page.settings.connectionTimeout * 1000;
|
||||
}
|
||||
|
||||
keepass.reconnect = async function(tab = null, connectionTimeout = page.settings.connectionTimeout) {
|
||||
keepassClient.connectToNative();
|
||||
keepass.generateNewKeyPair();
|
||||
const keyChangeResult = await keepass.changePublicKeys(tab, !!connectionTimeout, connectionTimeout).catch(() => false);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const defaultSettings = {
|
|||
bannerPosition: BannerPosition.TOP,
|
||||
checkUpdateKeePassXC: CHECK_UPDATE_NEVER,
|
||||
clearCredentialsTimeout: 10,
|
||||
connectionTimeout: 2,
|
||||
connectionTimeout: 1500,
|
||||
colorTheme: 'system',
|
||||
credentialSorting: SORT_BY_GROUP_AND_TITLE,
|
||||
debugLogging: false,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
"type": "integer"
|
||||
},
|
||||
"connectionTimeout": {
|
||||
"title": "Connection timeout to KeePassXC. Default (seconds): 2",
|
||||
"title": "Connection timeout to KeePassXC. Default (seconds): 1.5",
|
||||
"type": "integer"
|
||||
},
|
||||
"colorTheme": {
|
||||
|
|
|
|||
|
|
@ -534,10 +534,8 @@
|
|||
|
||||
<!-- Keepass connectiontimeout -->
|
||||
<div class="form-group mt-2 pb-1">
|
||||
<label for="connectionTimeout" data-i18n="optionsConnectionTimeout"></label>
|
||||
<div class="input-group w-25 mt-2">
|
||||
<input class="form-control form-control-sm" type="number" id="connectionTimeout" min="2" max="60" required>
|
||||
</div>
|
||||
<label id="connectionTimeoutLabel" class="font-weight-normal" for="connectionTimeout" data-i18n="optionsConnectionTimeout" data-i18n-placeholder="1.5"></label>
|
||||
<input type="range" class="form-range" id="connectionTimeout" name="connectionTimeout" min="1.5" max="60.0" step="0.5" value="1.5">
|
||||
<div class="form-text" data-i18n="optionsConnectionTimeoutHelpText"></div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ options.initGeneralSettings = async function() {
|
|||
$('#tab-general-settings input[type=radio]#checkUpdateOneMonth').value = CHECK_UPDATE_ONE_MONTH;
|
||||
$('#tab-general-settings input[type=radio]#checkUpdateNever').value = CHECK_UPDATE_NEVER;
|
||||
|
||||
$('#tab-general-settings input[type=range]').value = options.settings['redirectAllowance'];
|
||||
$('#tab-general-settings #redirectAllowance').value = options.settings['redirectAllowance'];
|
||||
$('#redirectAllowanceLabel').textContent = tr('optionsRedirectAllowance',
|
||||
options.settings['redirectAllowance'] === 11 ? 'Infinite' : String(options.settings['redirectAllowance']));
|
||||
|
||||
|
|
@ -124,7 +124,9 @@ options.initGeneralSettings = async function() {
|
|||
$('#tab-general-settings input#defaultGroup').value = options.settings['defaultGroup'];
|
||||
$('#tab-general-settings input#defaultPasskeyGroup').value = options.settings['defaultPasskeyGroup'];
|
||||
$('#tab-general-settings input#clearCredentialTimeout').value = options.settings['clearCredentialsTimeout'];
|
||||
$('#tab-general-settings input#connectionTimeout').value = options.settings['connectionTimeout'];
|
||||
const connectionTimeout = (options.settings['connectionTimeout']/1000);
|
||||
$('#tab-general-settings input#connectionTimeout').value = connectionTimeout;
|
||||
$('#connectionTimeoutLabel').textContent = tr('optionsConnectionTimeout', String(connectionTimeout));
|
||||
|
||||
const generalSettingsRadioInputs = document.querySelectorAll('#tab-general-settings input[type=radio]');
|
||||
for (const radio of generalSettingsRadioInputs) {
|
||||
|
|
@ -173,17 +175,22 @@ options.initGeneralSettings = async function() {
|
|||
await options.saveSettings();
|
||||
});
|
||||
|
||||
// Change label text dynamically with the range input
|
||||
$('#tab-general-settings input#connectionTimeout').addEventListener('input', function(e) {
|
||||
$('#connectionTimeoutLabel').textContent = tr('optionsConnectionTimeout', e.target.value);
|
||||
});
|
||||
|
||||
$('#tab-general-settings input#connectionTimeout').addEventListener('change', async function(e) {
|
||||
if (e.target.valueAsNumber < 2 || e.target.valueAsNumber > 60) {
|
||||
if (e.target.valueAsNumber < 1.5 || e.target.valueAsNumber > 60) {
|
||||
return;
|
||||
}
|
||||
|
||||
options.settings['connectionTimeout'] = e.target.valueAsNumber;
|
||||
options.settings['connectionTimeout'] = e.target.valueAsNumber * 1000;
|
||||
await options.saveSettings();
|
||||
});
|
||||
|
||||
// Change label text dynamically with the range input
|
||||
$('#tab-general-settings input[type=range]').addEventListener('input', function(e) {
|
||||
$('#tab-general-settings input#redirectAllowance').addEventListener('input', function(e) {
|
||||
const currentValue = e.target.valueAsNumber === 11 ? 'Infinite' : e.target.value;
|
||||
$('#redirectAllowanceLabel').textContent = tr('optionsRedirectAllowance', currentValue);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue