ApplicationManager and better memory management

This commit is contained in:
Mo Bitar
2020-03-23 19:59:55 -05:00
parent 7dc3dab90b
commit ee7cb1fce6
55 changed files with 36786 additions and 3046 deletions

View File

@@ -0,0 +1,78 @@
import template from '%/lock-screen.pug';
import { AppStateEvents } from '@/services/state';
import { PureCtrl } from './abstract/pure_ctrl';
const ELEMENT_ID_PASSCODE_INPUT = 'passcode-input';
class LockScreenCtrl extends PureCtrl {
/* @ngInject */
constructor(
$timeout,
) {
super($timeout);
this.formData = {};
}
$onInit() {
super.$onInit();
this.puppet.focusInput = () => {
this.passcodeInput.focus();
};
}
get passcodeInput() {
return document.getElementById(
ELEMENT_ID_PASSCODE_INPUT
);
}
/** @override */
async onAppStateEvent(eventName, data) {
if (eventName === AppStateEvents.WindowDidFocus) {
const input = this.passcodeInput;
if (input) {
input.focus();
}
}
}
async submitPasscodeForm() {
if (
!this.formData.passcode ||
this.formData.passcode.length === 0
) {
return;
}
this.passcodeInput.blur();
this.onValue()(this.formData.passcode);
}
forgotPasscode() {
this.formData.showRecovery = true;
}
beginDeleteData() {
this.application.alertService.confirm({
text: "Are you sure you want to clear all local data?",
destructive: true,
onConfirm: async () => {
await this.application.signOut();
await this.application.restart();
}
});
}
}
export class LockScreen {
constructor() {
this.restrict = 'E';
this.template = template;
this.controller = LockScreenCtrl;
this.controllerAs = 'ctrl';
this.bindToController = true;
this.scope = {
onValue: '&',
puppet: '='
};
}
}