feat: snjs app groups (#468)

* feat: snjs app groups

* fix: update snjs version to point to wip commit

* wip: account switcher

* feat: rename lock manager to auto lock service

* fix: more relevant sign out copy

* chore(deps): update snjs

* fix: use setTimeout instead of setImmediate

* feat: make account switcher expiremental feature

* chore(deps): upgrade snjs
This commit is contained in:
Mo Bitar
2020-09-15 10:55:32 -05:00
committed by GitHub
parent ae6ef50f88
commit 2b6abeebfc
46 changed files with 590 additions and 375 deletions

View File

@@ -1,3 +1,4 @@
import { ApplicationGroup } from './../ui_models/application_group';
import { WebApplication } from '@/ui_models/application';
import { isDesktopApplication } from '@/utils';
import { AppStateEvent } from '@/ui_models/app_state';
@@ -12,7 +13,7 @@ const LOCK_INTERVAL_ONE_HOUR = 3600 * MILLISECONDS_PER_SECOND;
const STORAGE_KEY_AUTOLOCK_INTERVAL = "AutoLockIntervalKey";
export class LockManager {
export class AutolockService {
private application: WebApplication
private unsubState: any
@@ -21,11 +22,13 @@ export class LockManager {
private lockAfterDate?: Date
private lockTimeout?: any
constructor(application: WebApplication) {
constructor(
application: WebApplication
) {
this.application = application;
setImmediate(() => {
setTimeout(() => {
this.observeVisibility();
});
}, 0);
}
observeVisibility() {
@@ -50,6 +53,10 @@ export class LockManager {
}
}
private lockApplication() {
this.application.lock();
}
async setAutoLockInterval(interval: number) {
return this.application!.setValue(
STORAGE_KEY_AUTOLOCK_INTERVAL,
@@ -118,7 +125,7 @@ export class LockManager {
this.lockAfterDate &&
new Date() > this.lockAfterDate
) {
this.application.lock();
this.lockApplication();
}
this.cancelAutoLockTimer();
} else {
@@ -132,9 +139,9 @@ export class LockManager {
return;
}
/**
* Use a timeout if possible, but if the computer is put to sleep, timeouts won't
* work. Need to set a date as backup. this.lockAfterDate does not need to be
* persisted, as living in memory is sufficient. If memory is cleared, then the
* Use a timeout if possible, but if the computer is put to sleep, timeouts won't
* work. Need to set a date as backup. this.lockAfterDate does not need to be
* persisted, as living in memory is sufficient. If memory is cleared, then the
* application will lock anyway.
*/
const addToNow = (seconds: number) => {
@@ -145,7 +152,7 @@ export class LockManager {
this.lockAfterDate = addToNow(interval / MILLISECONDS_PER_SECOND);
this.lockTimeout = setTimeout(() => {
this.cancelAutoLockTimer();
this.application.lock();
this.lockApplication();
this.lockAfterDate = undefined;
}, interval);
}

View File

@@ -2,7 +2,7 @@ export { AlertService } from './alertService';
export { ArchiveManager } from './archiveManager';
export { DesktopManager } from './desktopManager';
export { KeyboardManager } from './keyboardManager';
export { LockManager } from './lockManager';
export { AutolockService } from './autolock_service';
export { NativeExtManager } from './nativeExtManager';
export { PreferencesManager } from './preferencesManager';
export { StatusManager } from './statusManager';

View File

@@ -10,8 +10,8 @@ import {
Copy,
dictToArray
} from 'snjs';
import { PayloadContent } from '@node_modules/snjs/dist/@types/protocol/payloads/generator';
import { ComponentPermission } from '@node_modules/snjs/dist/@types/models/app/component';
import { PayloadContent } from 'snjs/dist/@types/protocol/payloads/generator';
import { ComponentPermission } from 'snjs/dist/@types/models/app/component';
/** A class for handling installation of system extensions */
export class NativeExtManager extends ApplicationService {