mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 12:15:20 +08:00
efcefbaf78
Touch devices can be any size and can use (bluetooth/usb-c mouse/keyboard) these days. It's all about pixels and currently if the mode is mobile/no-mobile (this can be improved later).
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
import ko from 'ko';
|
|
|
|
import { StorageResultType } from 'Common/Enums';
|
|
|
|
import Remote from 'Remote/User/Fetch';
|
|
|
|
import { popup, command } from 'Knoin/Knoin';
|
|
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
|
|
|
@popup({
|
|
name: 'View/Popup/TwoFactorTest',
|
|
templateID: 'PopupsTwoFactorTest'
|
|
})
|
|
class TwoFactorTestPopupView extends AbstractViewNext {
|
|
constructor() {
|
|
super();
|
|
|
|
this.code = ko.observable('');
|
|
this.code.focused = ko.observable(false);
|
|
this.code.status = ko.observable(null);
|
|
|
|
this.koTestedTrigger = null;
|
|
|
|
this.testing = ko.observable(false);
|
|
}
|
|
|
|
@command((self) => self.code() && !self.testing())
|
|
testCodeCommand() {
|
|
this.testing(true);
|
|
Remote.testTwoFactor((result, data) => {
|
|
this.testing(false);
|
|
this.code.status(StorageResultType.Success === result && data && !!data.Result);
|
|
|
|
if (this.koTestedTrigger && this.code.status()) {
|
|
this.koTestedTrigger(true);
|
|
}
|
|
}, this.code());
|
|
}
|
|
|
|
clearPopup() {
|
|
this.code('');
|
|
this.code.focused(false);
|
|
this.code.status(null);
|
|
this.testing(false);
|
|
|
|
this.koTestedTrigger = null;
|
|
}
|
|
|
|
onShow(koTestedTrigger) {
|
|
this.clearPopup();
|
|
|
|
this.koTestedTrigger = koTestedTrigger;
|
|
}
|
|
|
|
onShowWithDelay() {
|
|
// rl.settings.app('mobile') ||
|
|
this.code.focused(true);
|
|
}
|
|
}
|
|
|
|
export { TwoFactorTestPopupView, TwoFactorTestPopupView as default };
|