diff --git a/qml/Main.qml b/qml/Main.qml index 52f4b220..ba6eacfe 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -108,6 +108,7 @@ ApplicationWindow { settings.slot2 = settingsDialog.slot2 settings.slot1digits = settingsDialog.slot1digits settings.slot2digits = settingsDialog.slot2digits + refreshDependingOnMode(true) } } @@ -505,23 +506,6 @@ ApplicationWindow { onTriggered: device.refresh(refreshDependingOnMode) } - function refreshDependingOnMode() { - if (hasDevice) { - if (settings.slotMode) { - device.refreshSlotCredentials([settings.slot1, settings.slot2], getSlotDigitsSettings()) - } else { - device.refreshCCIDCredentials() - } - } - } - - function getSlotDigitsSettings() { - var slot1digits = settings.slot1digits === 1 ? 8 : 6 - var slot2digits = settings.slot2digits === 1 ? 8 : 6 - return [slot1digits, slot2digits] - } - - Timer { id: progressBarTimer interval: 100 @@ -531,7 +515,7 @@ ApplicationWindow { onTriggered: { var timeLeft = expiration - (Date.now() / 1000) if (timeLeft <= 0 && progressBar.value > 0) { - device.refresh() + device.refresh(refreshDependingOnMode) totpCoolDowns = [] } progressBar.value = timeLeft @@ -557,6 +541,22 @@ ApplicationWindow { *******/ + function refreshDependingOnMode(force) { + if (hasDevice) { + if (settings.slotMode) { + device.refreshSlotCredentials([settings.slot1, settings.slot2], getSlotDigitsSettings(), force) + } else { + device.refreshCCIDCredentials(force) + } + } + } + + function getSlotDigitsSettings() { + var slot1digits = settings.slot1digits === 1 ? 8 : 6 + var slot2digits = settings.slot2digits === 1 ? 8 : 6 + return [slot1digits, slot2digits] + } + function filteredCredentials(creds, search) { var result = [] if (creds != null) { diff --git a/qml/YubiKey.qml b/qml/YubiKey.qml index 22c6c90c..5955b266 100644 --- a/qml/YubiKey.qml +++ b/qml/YubiKey.qml @@ -84,16 +84,17 @@ Python { }) } - function refreshCCIDCredentials() { + function refreshCCIDCredentials(force) { var now = Math.floor(Date.now() / 1000) - if (validated && nextRefresh < now) { - refreshCredentials() + if (force || (validated && nextRefresh < now)) { + do_call('yubikey.controller.refresh_credentials', [now, passwordKey], + handleCredentials) } } - function refreshSlotCredentials(slots, digits) { + function refreshSlotCredentials(slots, digits, force) { var now = Math.floor(Date.now() / 1000) - if (nextRefresh < now) { + if (force || (nextRefresh < now)) { do_call('yubikey.controller.refresh_slot_credentials', [slots, digits, now], handleCredentials) } } @@ -130,13 +131,6 @@ Python { }) } - function refreshCredentials() { - var now = Math.floor(Date.now() / 1000) - do_call('yubikey.controller.refresh_credentials', [now, passwordKey], - handleCredentials) - } - - function handleCredentials(creds) { var result = [] var minExpiration = (Date.now() / 1000) + 10000