Force refresh on settings closed

This commit is contained in:
Dag Heyman 2017-02-23 12:18:20 +01:00
parent 66693a842c
commit b50b63a94c
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
2 changed files with 24 additions and 30 deletions

View File

@ -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) {

View File

@ -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