displaying a message on the open screen

pull/1856/head
antelle 2 years ago
parent 8fc6f49fb4
commit cdc3f5e1df
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C

@ -218,7 +218,7 @@ const AutoType = {
logger.debug('auto-type event delayed');
this.focusMainWindow();
try {
await AppModel.instance.unlockAnyFile();
await AppModel.instance.unlockAnyFile('autoTypeUnlockMessage');
} catch {
logger.debug('auto-type event canceled');
return;

@ -361,6 +361,7 @@
"autoTypeSelectionHintOpt": "Only type the username",
"autoTypeSelectionHintShift": "Other fields",
"autoTypeSelectionOtp": "One-time code",
"autoTypeUnlockMessage": "Unlock to auto-type",
"appSecWarn": "Not Secure!",
"appSecWarnBody1": "You have loaded this app with an insecure connection. Someone may be watching you and stealing your passwords. We strongly advise you to stop, unless you clearly understand what you're doing.",

@ -186,6 +186,7 @@ class AppModel {
this.appLogger.info('Running pending file unlock operation');
this.fileUnlockPromise.resolve(file);
this.fileUnlockPromise = null;
Events.emit('unlock-message-changed', null);
}
return true;
@ -1431,19 +1432,25 @@ class AppModel {
}
}
unlockAnyFile() {
unlockAnyFile(unlockRes) {
this.rejectPendingFileUnlockPromise('Replaced with a new operation');
return new Promise((resolve, reject) => {
this.fileUnlockPromise = { resolve, reject };
this.fileUnlockPromise = { resolve, reject, unlockRes };
this.appLogger.info('Pending file unlock operation is set');
Events.emit('unlock-message-changed', unlockRes);
});
}
get unlockMessageRes() {
return this.fileUnlockPromise?.unlockRes;
}
rejectPendingFileUnlockPromise(reason) {
if (this.fileUnlockPromise) {
this.appLogger.info('Cancel pending file unlock operation', reason);
this.fileUnlockPromise.reject(new Error(reason));
this.fileUnlockPromise = null;
Events.emit('unlock-message-changed', null);
}
}

@ -52,6 +52,7 @@ class OpenView extends View {
'click .open__settings-yubikey': 'selectYubiKeyChalResp',
'click .open__last-item': 'openLast',
'click .open__icon-generate': 'toggleGenerator',
'click .open__message-cancel-btn': 'openMessageCancelClick',
dragover: 'dragover',
dragleave: 'dragleave',
drop: 'drop'
@ -76,6 +77,7 @@ class OpenView extends View {
this.onKey(Keys.DOM_VK_UP, this.moveOpenFileSelectionUp, null, 'open');
this.listenTo(Events, 'main-window-focus', this.windowFocused.bind(this));
this.listenTo(Events, 'usb-devices-changed', this.usbDevicesChanged.bind(this));
this.listenTo(Events, 'unlock-message-changed', this.unlockMessageChanged.bind(this));
this.once('remove', () => {
this.passwordInput.reset();
});
@ -118,6 +120,7 @@ class OpenView extends View {
canOpenKeyFromDropbox: !Launcher && Storage.dropbox.enabled,
demoOpened: this.model.settings.demoOpened,
storageProviders,
unlockMessageRes: this.model.unlockMessageRes,
canOpen: this.model.settings.canOpen,
canOpenDemo: this.model.settings.canOpenDemo,
canOpenSettings: this.model.settings.canOpenSettings,
@ -1159,6 +1162,20 @@ class OpenView extends View {
}
}
}
unlockMessageChanged(unlockMessageRes) {
const messageEl = this.el.querySelector('.open__message');
messageEl.classList.toggle('hide', !unlockMessageRes);
if (unlockMessageRes) {
const contentEl = this.el.querySelector('.open__message-content');
contentEl.innerText = Locale[unlockMessageRes];
}
}
openMessageCancelClick() {
this.model.rejectPendingFileUnlockPromise('User canceled');
}
}
export { OpenView };

@ -340,6 +340,32 @@
margin-top: 1em;
}
}
&__message {
display: flex;
justify-content: space-between;
min-width: 20vw;
background: var(--secondary-background-color);
border-radius: var(--block-border-radius);
margin-bottom: $large-padding;
&-content {
padding: $medium-padding;
padding-right: $small-spacing;
}
&-cancel-btn {
padding: $medium-padding;
padding-left: $small-spacing;
cursor: pointer;
opacity: 0.5;
transition: opacity $base-duration $base-timing;
&:hover {
opacity: 1;
}
&-icon {
vertical-align: bottom;
}
}
}
}
.open-list {

@ -1,5 +1,11 @@
<div class="open">
<input type="file" class="open__file-ctrl hide-by-pos" />
<div class="open__message {{#unless unlockMessageRes}}hide{{/unless}}">
<div class="open__message-content">{{#if unlockMessageRes}}{{res unlockMessageRes}}{{/if}}</div>
<div class="open__message-cancel-btn" title="{{res 'alertCancel'}}" tip-placement="left">
<i class="fa fa-times-circle open__message-cancel-btn-icon"></i>
</div>
</div>
<div class="open__icons">
{{#if canOpen}}
<div class="open__icon open__icon-open" tabindex="1" id="open__icon-open">

@ -7,7 +7,8 @@ Release notes
`*` password generator now includes all selected character ranges
`+` better Touch ID error messages
`-` legacy auto-type removed
`-` fixed a crash after disabling USB devices on Linux
`+` displaying the reason why unlock is requested
`-` fixed a crash after disabling USB devices on Linux
`+` tightened content security policy
##### v1.17.6 (2021-04-09)

Loading…
Cancel
Save