Improvements to native ext mgr and password wizard

This commit is contained in:
Mo Bitar
2020-02-17 12:08:21 -06:00
parent 6fc53f3920
commit c6198a4612
12 changed files with 544 additions and 594 deletions

View File

@@ -14,14 +14,14 @@ export class PureCtrl {
this.$timeout = $timeout;
this.appState = appState;
this.application = application;
this.state = {};
this.state = this.getInitialState();
this.props = {};
$scope.$on('$destroy', () => {
this.unsubApp();
this.unsubState();
});
}
$onInit() {
this.addAppStateObserver();
this.addAppEventObserver();
@@ -29,8 +29,13 @@ export class PureCtrl {
/** @private */
async resetState() {
this.state = {};
await this.setState({});
this.state = this.getInitialState();
await this.setState(this.state);
}
/** @override */
getInitialState() {
return {};
}
async setState(state) {

View File

@@ -63,8 +63,23 @@ class EditorCtrl extends PureCtrl {
this.desktopManager = desktopManager;
this.keyboardManager = keyboardManager;
this.preferencesManager = preferencesManager;
this.leftPanelPuppet = {
onReady: () => this.reloadPreferences()
};
this.rightPanelPuppet = {
onReady: () => this.reloadPreferences()
};
this.addSyncStatusObserver();
this.registerKeyboardShortcuts();
/** Used by .pug template */
this.prefKeyMonospace = PrefKeys.EditorMonospaceEnabled;
this.prefKeySpellcheck = PrefKeys.EditorSpellcheck;
this.prefKeyMarginResizers = PrefKeys.EditorResizersEnabled;
}
this.state = {
/** @override */
getInitialState() {
return {
componentStack: [],
editorDebounce: EDITOR_DEBOUNCE,
isDesktop: isDesktopApplication(),
@@ -73,21 +88,8 @@ class EditorCtrl extends PureCtrl {
tagsString: ''
}
};
this.leftPanelPuppet = {
onReady: () => this.reloadPreferences()
};
this.rightPanelPuppet = {
onReady: () => this.reloadPreferences()
};
this.addSyncStatusObserver();
this.registerKeyboardShortcuts();
/** Used by .pug template */
this.prefKeyMonospace = PrefKeys.EditorMonospaceEnabled;
this.prefKeySpellcheck = PrefKeys.EditorSpellcheck;
this.prefKeyMarginResizers = PrefKeys.EditorResizersEnabled;
}
onAppLaunch() {
super.onAppLaunch();
this.streamItems();
@@ -214,6 +216,9 @@ class EditorCtrl extends PureCtrl {
noteStatus: null
});
if (!note) {
this.setState({
noteReady: false
});
return;
}
const associatedEditor = this.editorForNote(note);

View File

@@ -2,6 +2,7 @@ import { Challenges, ChallengeResponse } from 'snjs';
import { getPlatformString } from '@/utils';
import template from '%/root.pug';
import { AppStateEvents } from '@/state';
import angular from 'angular';
import {
PANEL_NAME_NOTES,
PANEL_NAME_TAGS
@@ -16,6 +17,7 @@ import { PureCtrl } from './abstract/pure_ctrl';
class RootCtrl extends PureCtrl {
/* @ngInject */
constructor(
$compile,
$location,
$scope,
$rootScope,
@@ -31,6 +33,7 @@ class RootCtrl extends PureCtrl {
super($scope, $timeout, application, appState);
this.$location = $location;
this.$rootScope = $rootScope;
this.$compile = $compile;
this.desktopManager = desktopManager;
this.lockManager = lockManager;
this.statusManager = statusManager;
@@ -46,13 +49,14 @@ class RootCtrl extends PureCtrl {
onAppStart() {
super.onAppStart();
this.overrideComponentManagerFunctions();
this.application.componentManager.setDesktopManager(this.desktopManager);
this.setState({ ready: true });
}
onAppLaunch() {
super.onAppLaunch();
this.setState({ needsUnlock: false });
this.application.componentManager.setDesktopManager(this.desktopManager);
this.application.registerService(this.themeManager);
this.handleAutoSignInFromParams();
}
@@ -119,6 +123,25 @@ class RootCtrl extends PureCtrl {
}
}
overrideComponentManagerFunctions() {
function openModalComponent(component) {
const scope = this.$rootScope.$new(true);
scope.component = component;
const el = this.$compile("<component-modal component='component' class='sk-modal'></component-modal>")(scope);
angular.element(document.body).append(el);
}
function presentPermissionsDialog(dialog) {
const scope = this.$rootScope.$new(true);
scope.permissionsString = dialog.permissionsString;
scope.component = dialog.component;
scope.callback = dialog.callback;
const el = this.$compile("<permissions-modal component='component' permissions-string='permissionsString' callback='callback' class='sk-modal'></permissions-modal>")(scope);
angular.element(document.body).append(el);
}
this.application.componentManager.openModalComponent = openModalComponent.bind(this);
this.application.componentManager.presentPermissionsDialog = presentPermissionsDialog.bind(this);
}
// addSyncStatusObserver() {
// this.syncStatusObserver = syncManager.registerSyncStatusObserver((status) => {
// if (status.retrievedCount > 20) {