This commit is contained in:
Mo Bitar
2020-02-12 17:47:00 -06:00
parent a364a9ec03
commit 2daef55827
14 changed files with 212 additions and 230 deletions

View File

@@ -60,18 +60,18 @@ export class PureCtrl {
this.onAppStart();
}
if (!this.appState.isLocked()) {
this.onAppUnlock();
this.onAppLaunch();
}
this.unsubApp = this.application.addEventObserver(async (eventName) => {
this.onAppEvent(eventName);
if (eventName === ApplicationEvents.Started) {
await this.resetState();
await this.onAppStart();
} else if (eventName === ApplicationEvents.Unlocked) {
await this.onAppUnlock();
} else if (eventName === ApplicationEvents.Launched) {
await this.onAppLaunch();
} else if (eventName === ApplicationEvents.CompletedSync) {
this.onAppSync();
} else if (eventName === ApplicationEvents.KeyStatusChange) {
} else if (eventName === ApplicationEvents.KeyStatusChanged) {
this.onAppKeyChange();
}
});
@@ -89,7 +89,7 @@ export class PureCtrl {
/** Optional override */
}
async onAppUnlock() {
async onAppLaunch() {
/** Optional override */
}

View File

@@ -88,8 +88,8 @@ class EditorCtrl extends PureCtrl {
this.prefKeyMarginResizers = PrefKeys.EditorResizersEnabled;
}
onAppUnlock() {
super.onAppUnlock();
onAppLaunch() {
super.onAppLaunch();
this.streamItems();
this.registerComponentHandler();
}

View File

@@ -48,8 +48,8 @@ class FooterCtrl extends PureCtrl {
});
}
onAppUnlock() {
super.onAppUnlock();
onAppLaunch() {
super.onAppLaunch();
this.application.hasPasscode().then((value) => {
this.setState({
hasPasscode: value

View File

@@ -78,8 +78,8 @@ class NotesCtrl extends PureCtrl {
});
}
onAppUnlock() {
super.onAppUnlock();
onAppLaunch() {
super.onAppLaunch();
this.streamNotesAndTags();
this.reloadPreferences();
}

View File

@@ -1,4 +1,4 @@
import { Challenges, ChallengeResponse, ApplicationEvents } from 'snjs';
import { Challenges, ChallengeResponse } from 'snjs';
import { getPlatformString } from '@/utils';
import template from '%/root.pug';
import { AppStateEvents } from '@/state';
@@ -46,12 +46,12 @@ class RootCtrl extends PureCtrl {
onAppStart() {
super.onAppStart();
this.setState({ ready: false });
this.setState({ ready: true });
}
onAppUnlock() {
super.onAppUnlock();
this.setState({ ready: true, needsUnlock: false });
onAppLaunch() {
super.onAppLaunch();
this.setState({ needsUnlock: false });
this.application.componentManager.setDesktopManager(this.desktopManager);
this.application.registerService(this.themeManager);
this.handleAutoSignInFromParams();

View File

@@ -34,8 +34,8 @@ class TagsPanelCtrl extends PureCtrl {
this.registerComponentHandler();
}
onAppUnlock() {
super.onAppUnlock();
onAppLaunch() {
super.onAppLaunch();
this.loadPreferences();
this.beginStreamingItems();
const smartTags = this.application.getSmartTags();

View File

@@ -60,14 +60,14 @@ class AccountMenuCtrl extends PureCtrl {
};
this.syncStatus = this.application.getSyncStatus();
}
async onAppKeyChange() {
super.onAppKeyChange();
this.setState(await this.refreshedCredentialState());
}
async onAppUnlock() {
super.onAppUnlock();
async onAppLaunch() {
super.onAppLaunch();
this.setState(await this.refreshedCredentialState());
this.loadHost();
this.checkForSecurityUpdate();
@@ -477,11 +477,11 @@ class AccountMenuCtrl extends PureCtrl {
});
return;
}
const func = this.state.formData.changingPasscode
? this.application.changePasscode.bind(this.application)
: this.application.setPasscode.bind(this.application);
func(passcode, async () => {
await this.setFormDataState({
(this.state.formData.changingPasscode
? this.application.changePasscode(passcode)
: this.application.setPasscode(passcode)
).then(() => {
this.setFormDataState({
passcode: null,
confirmPasscode: null,
showPasscodeForm: false

View File

@@ -14,8 +14,8 @@ class PrivilegesManagementModalCtrl extends PureCtrl {
this.application = application;
}
onAppUnlock() {
super.onAppUnlock();
onAppLaunch() {
super.onAppLaunch();
this.hasPasscode = this.application.hasPasscode();
this.hasAccount = !this.application.noAccount();
this.reloadPrivileges();

View File

@@ -16,7 +16,7 @@ export class NativeExtManager {
this.extManagerId = 'org.standardnotes.extensions-manager';
this.batchManagerId = 'org.standardnotes.batch-manager';
this.unsub = application.addSingleEventObserver(ApplicationEvents.Unlocked, () => {
this.unsub = application.addSingleEventObserver(ApplicationEvents.Launched, () => {
this.reload();
this.streamChanges();
});

View File

@@ -25,7 +25,7 @@ export class PreferencesManager {
) {
this.application = application;
this.appState = appState;
this.unsub = application.addSingleEventObserver(ApplicationEvents.Unlocked, () => {
this.unsub = application.addSingleEventObserver(ApplicationEvents.Launched, () => {
this.streamPreferences();
this.loadSingleton();
});

View File

@@ -42,7 +42,7 @@ export class AppState {
this.unsubApp = this.application.addEventObserver(async (eventName) => {
if (eventName === ApplicationEvents.Started) {
this.locked = true;
} else if (eventName === ApplicationEvents.Unlocked) {
} else if (eventName === ApplicationEvents.Launched) {
this.locked = false;
}
});

View File

@@ -110,7 +110,7 @@ export class WebDeviceInterface extends DeviceInterface {
}
/** @keychian */
async getRawKeychainValue() {
async getKeychainValue() {
const value = localStorage.getItem(KEYCHAIN_STORAGE_KEY);
if(value) {
return JSON.parse(value);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long