mirror of https://github.com/keeweb/keeweb
refreshing the list of yubikeys on the start screen
parent
b90e84be42
commit
0f582e3248
|
@ -13,7 +13,7 @@ const Timeouts = {
|
|||
LinkDownloadRevoke: 10 * 1000 * 60,
|
||||
DefaultHttpRequest: 60000,
|
||||
ExternalDeviceReconnect: 3000,
|
||||
ExternalDeviceAfterReconnect: 500
|
||||
ExternalDeviceAfterReconnect: 1000
|
||||
};
|
||||
|
||||
export { Timeouts };
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { Events } from 'framework/events';
|
||||
import { View } from 'framework/views/view';
|
||||
import { YubiKey } from 'comp/app/yubikey';
|
||||
import { Locale } from 'util/locale';
|
||||
import { Timeouts } from 'const/timeouts';
|
||||
import template from 'templates/open-chal-resp.hbs';
|
||||
|
||||
class OpenChalRespView extends View {
|
||||
|
@ -13,7 +15,38 @@ class OpenChalRespView extends View {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
this.listenTo(Events, 'usb-devices-changed', this.usbDevicesChanged);
|
||||
|
||||
this.checkDevices();
|
||||
}
|
||||
|
||||
render() {
|
||||
let error = this.error;
|
||||
|
||||
if (this.yubiKeys && !this.yubiKeys.length) {
|
||||
error = Locale.openChalRespErrorEmpty;
|
||||
}
|
||||
|
||||
super.render({
|
||||
error,
|
||||
yubiKeys: this.yubiKeys,
|
||||
loading: !this.yubiKeys && !this.error
|
||||
});
|
||||
}
|
||||
|
||||
usbDevicesChanged() {
|
||||
setTimeout(() => {
|
||||
if (!this.removed) {
|
||||
this.checkDevices();
|
||||
}
|
||||
}, Timeouts.ExternalDeviceAfterReconnect);
|
||||
}
|
||||
|
||||
checkDevices() {
|
||||
YubiKey.list((err, yubiKeys) => {
|
||||
if (this.removed) {
|
||||
return;
|
||||
}
|
||||
this.error = err;
|
||||
this.yubiKeys = [];
|
||||
if (yubiKeys) {
|
||||
|
@ -31,20 +64,6 @@ class OpenChalRespView extends View {
|
|||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
let error = this.error;
|
||||
|
||||
if (this.yubiKeys && !this.yubiKeys.length) {
|
||||
error = Locale.openChalRespErrorEmpty;
|
||||
}
|
||||
|
||||
super.render({
|
||||
error,
|
||||
yubiKeys: this.yubiKeys,
|
||||
loading: !this.yubiKeys && !this.error
|
||||
});
|
||||
}
|
||||
|
||||
itemClick(e) {
|
||||
const el = e.target.closest('[data-serial]');
|
||||
const { serial, slot } = el.dataset;
|
||||
|
|
Loading…
Reference in New Issue