This commit is contained in:
Mo Bitar
2020-02-09 00:34:14 -06:00
parent b5ec64f102
commit 046f6ca5b9
19 changed files with 919 additions and 635 deletions

View File

@@ -12,8 +12,8 @@ import { WebDeviceInterface } from '@/web_device_interface';
export class Application extends SNApplication { export class Application extends SNApplication {
/* @ngInject */ /* @ngInject */
constructor($compile, $rootScope) { constructor($compile, $timeout, $rootScope) {
const deviceInterface = new WebDeviceInterface(); const deviceInterface = new WebDeviceInterface({timeout: $timeout});
super({ super({
environment: Environments.Web, environment: Environments.Web,
platform: platformFromString(getPlatformString()), platform: platformFromString(getPlatformString()),

View File

@@ -701,7 +701,7 @@ class EditorCtrl extends PureCtrl {
this.saveTags({ strings: strings }); this.saveTags({ strings: strings });
} }
saveTags({ strings } = {}) { async saveTags({ strings } = {}) {
if (!strings && this.state.mutable.tagsString === this.state.note.tagsString()) { if (!strings && this.state.mutable.tagsString === this.state.note.tagsString()) {
return; return;
} }
@@ -732,7 +732,7 @@ class EditorCtrl extends PureCtrl {
); );
if (!existingRelationship) { if (!existingRelationship) {
tags.push( tags.push(
this.application.findOrCreateTag({ title: tagString }) await this.application.findOrCreateTag({ title: tagString })
); );
} }
} }

View File

@@ -18,6 +18,12 @@ class LockScreenCtrl {
this.addDestroyHandler(); this.addDestroyHandler();
} }
$onInit() {
this.puppet.focusInput = () => {
this.passcodeInput.focus();
};
}
get passcodeInput() { get passcodeInput() {
return document.getElementById( return document.getElementById(
ELEMENT_ID_PASSCODE_INPUT ELEMENT_ID_PASSCODE_INPUT
@@ -49,15 +55,7 @@ class LockScreenCtrl {
return; return;
} }
this.passcodeInput.blur(); this.passcodeInput.blur();
const success = await this.onValue()(this.formData.passcode); this.onValue()(this.formData.passcode);
if(!success) {
this.application.alertManager.alert({
text: "Invalid passcode. Please try again.",
onClose: () => {
this.passcodeInput.focus();
}
});
}
} }
forgotPasscode() { forgotPasscode() {
@@ -85,6 +83,7 @@ export class LockScreen {
this.bindToController = true; this.bindToController = true;
this.scope = { this.scope = {
onValue: '&', onValue: '&',
puppet: '='
}; };
} }
} }

View File

@@ -1,5 +1,4 @@
import _ from 'lodash'; import { Challenges, ChallengeResponse } from 'snjs';
import { Challenges } from 'snjs';
import { getPlatformString } from '@/utils'; import { getPlatformString } from '@/utils';
import template from '%/root.pug'; import template from '%/root.pug';
import { AppStateEvents } from '@/state'; import { AppStateEvents } from '@/state';
@@ -46,20 +45,48 @@ class RootCtrl extends PureCtrl {
this.loadApplication(); this.loadApplication();
this.addAppStateObserver(); this.addAppStateObserver();
this.addDragDropHandlers(); this.addDragDropHandlers();
application.onReady(() => { application.onReady(() => {
this.handleAutoSignInFromParams(); this.handleAutoSignInFromParams();
}); });
this.lockScreenPuppet = {
focusInput: () => {}
};
}
async watchLockscreenValue() {
return new Promise((resolve) => {
const onLockscreenValue = (value) => {
resolve(new ChallengeResponse({
challenge: Challenges.LocalPasscode,
value: value
}));
};
this.setState({ onLockscreenValue });
});
} }
async loadApplication() { async loadApplication() {
await this.application.prepareForLaunch({ await this.application.prepareForLaunch({
callbacks: { callbacks: {
authChallengeResponses: async (challenges) => { requiresChallengeResponses: async (challenges) => {
console.log("Needs challenge repsonses", challenges);
if (challenges.includes(Challenges.LocalPasscode)) { if (challenges.includes(Challenges.LocalPasscode)) {
this.setState({ needsUnlock: true }); this.setState({ needsUnlock: true });
} }
return this.watchLockscreenValue();
},
handleChallengeFailures: (responses) => {
for(const response of responses) {
if(response.challenge === Challenges.LocalPasscode) {
this.application.alertManager.alert({
text: "Invalid passcode. Please try again.",
onClose: () => {
this.lockScreenPuppet.focusInput();
}
});
}
}
}, },
onReady: async () => { onReady: async () => {
await this.appState.setApplicationReady(); await this.appState.setApplicationReady();

View File

@@ -36,6 +36,10 @@ class TagsPanelCtrl extends PureCtrl {
}); });
this.selectTag(smartTags[0]); this.selectTag(smartTags[0]);
}); });
application.onSync(() => {
this.reloadNoteCounts();
});
} }
beginStreamingItems() { beginStreamingItems() {

View File

@@ -59,19 +59,27 @@ class AccountMenuCtrl extends PureCtrl {
}, },
mutable: {} mutable: {}
}; };
application.onReady(() => { application.onReady(async () => {
this.setState({ this.setState(await this.refreshedCredentialState());
user: this.application.getUser(),
canAddPasscode: !this.application.isEphemeralSession(),
});
this.loadHost(); this.loadHost();
this.checkForSecurityUpdate(); this.checkForSecurityUpdate();
this.reloadAutoLockInterval(); this.reloadAutoLockInterval();
this.loadBackupsAvailability(); this.loadBackupsAvailability();
}); });
application.onCredentialChange(async () => {
this.setState(await this.refreshedCredentialState());
});
this.syncStatus = this.application.getSyncStatus(); this.syncStatus = this.application.getSyncStatus();
} }
async refreshedCredentialState() {
return {
user: this.application.getUser(),
canAddPasscode: !this.application.isEphemeralSession(),
hasPasscode: await this.application.hasPasscode()
};
}
$onInit() { $onInit() {
this.initProps({ this.initProps({
closeFunction: this.closeFunction closeFunction: this.closeFunction
@@ -473,10 +481,6 @@ class AccountMenuCtrl extends PureCtrl {
} }
} }
hasPasscode() {
return this.application.hasPasscode();
}
addPasscodeClicked() { addPasscodeClicked() {
this.setFormDataState({ this.setFormDataState({
showPasscodeForm: true showPasscodeForm: true

View File

@@ -38,7 +38,7 @@ class PasswordWizardCtrl {
this.title = "Change Password"; this.title = "Change Password";
this.changePassword = true; this.changePassword = true;
} else if (this.type === 'upgrade-security') { } else if (this.type === 'upgrade-security') {
this.title = "Security Update"; this.title = "Account Update";
this.securityUpdate = true; this.securityUpdate = true;
} }
this.continueTitle = DEFAULT_CONTINUE_TITLE; this.continueTitle = DEFAULT_CONTINUE_TITLE;
@@ -135,7 +135,7 @@ class PasswordWizardCtrl {
if (this.changePassword) { if (this.changePassword) {
this.formData.status = "Successfully changed password."; this.formData.status = "Successfully changed password.";
} else if (this.securityUpdate) { } else if (this.securityUpdate) {
this.formData.status = "Successfully performed security update."; this.formData.status = "Successfully performed account update.";
} }
} }

View File

@@ -9,11 +9,13 @@ class RevisionPreviewModalCtrl {
constructor( constructor(
$element, $element,
$scope, $scope,
$timeout $timeout,
application
) { ) {
this.$element = $element; this.$element = $element;
this.$scope = $scope; this.$scope = $scope;
this.$timeout = $timeout; this.$timeout = $timeout;
this.application = application;
this.configure(); this.configure();
$scope.$on('$destroy', () => { $scope.$on('$destroy', () => {
if (this.identifier) { if (this.identifier) {

View File

@@ -1,13 +1,8 @@
/* eslint-disable prefer-promise-reject-errors */
import { SNAlertManager } from 'snjs'; import { SNAlertManager } from 'snjs';
import { SKAlert } from 'sn-stylekit'; import { SKAlert } from 'sn-stylekit';
export class AlertManager extends SNAlertManager { export class AlertManager extends SNAlertManager {
/* @ngInject */
constructor($timeout) {
super();
this.$timeout = $timeout;
}
async alert({ async alert({
title, title,
text, text,
@@ -21,7 +16,7 @@ export class AlertManager extends SNAlertManager {
style: "neutral", style: "neutral",
action: async () => { action: async () => {
if(onClose) { if(onClose) {
this.$timeout(onClose); this.deviceInterface.timeout(onClose);
} }
resolve(true); resolve(true);
} }
@@ -48,7 +43,7 @@ export class AlertManager extends SNAlertManager {
style: "neutral", style: "neutral",
action: async () => { action: async () => {
if(onCancel) { if(onCancel) {
this.$timeout(onCancel); this.deviceInterface.timeout(onCancel);
} }
reject(false); reject(false);
} }
@@ -58,7 +53,7 @@ export class AlertManager extends SNAlertManager {
style: destructive ? "danger" : "info", style: destructive ? "danger" : "info",
action: async () => { action: async () => {
if(onConfirm) { if(onConfirm) {
this.$timeout(onConfirm); this.deviceInterface.timeout(onConfirm);
} }
resolve(true); resolve(true);
} }

View File

@@ -16,14 +16,11 @@ export class GodService {
if (this.application.noAccount()) { if (this.application.noAccount()) {
return false; return false;
} }
const updateAvailable = await this.application.protocolService.upgradeAvailable();
const latest = await this.application.getUserVersion();
const updateAvailable = await this.protocolVersion() !== latest;
if (updateAvailable !== this.securityUpdateAvailable) { if (updateAvailable !== this.securityUpdateAvailable) {
this.securityUpdateAvailable = updateAvailable; this.securityUpdateAvailable = updateAvailable;
this.$rootScope.$broadcast("security-update-status-changed"); this.$rootScope.$broadcast("security-update-status-changed");
} }
return this.securityUpdateAvailable; return this.securityUpdateAvailable;
} }

View File

@@ -7,10 +7,11 @@ export class WebDeviceInterface extends DeviceInterface {
constructor({ constructor({
namespace, namespace,
timeout
} = {}) { } = {}) {
super({ super({
namespace, namespace,
timeout: setTimeout.bind(getGlobalScope()), timeout: timeout || setTimeout.bind(getGlobalScope()),
interval: setInterval.bind(getGlobalScope()) interval: setInterval.bind(getGlobalScope())
}); });
this.createDatabase(); this.createDatabase();

View File

@@ -201,7 +201,7 @@
ng-if='self.state.securityUpdateAvailable' ng-if='self.state.securityUpdateAvailable'
) )
.inline.sk-circle.small.success.mr-8 .inline.sk-circle.small.success.mr-8
.inline Security Update Available .inline Account Update Available
.sk-panel-section .sk-panel-section
.sk-panel-section-title Encryption .sk-panel-section-title Encryption
.sk-panel-section-subtitle.info(ng-if='self.state.encryptionEnabled') .sk-panel-section-subtitle.info(ng-if='self.state.encryptionEnabled')
@@ -210,7 +210,7 @@
| {{self.state.encryptionStatusString}} | {{self.state.encryptionStatusString}}
.sk-panel-section .sk-panel-section
.sk-panel-section-title Passcode Lock .sk-panel-section-title Passcode Lock
div(ng-if='!self.hasPasscode()') div(ng-if='!self.state.hasPasscode')
div(ng-if='self.state.canAddPasscode') div(ng-if='self.state.canAddPasscode')
.sk-panel-row(ng-if='!self.state.formData.showPasscodeForm') .sk-panel-row(ng-if='!self.state.formData.showPasscodeForm')
.sk-button.info( .sk-button.info(
@@ -247,7 +247,7 @@
a.neutral.sk-a.sk-panel-row( a.neutral.sk-a.sk-panel-row(
ng-click='self.state.formData.showPasscodeForm = false' ng-click='self.state.formData.showPasscodeForm = false'
) Cancel ) Cancel
div(ng-if='self.hasPasscode() && !self.state.formData.showPasscodeForm') div(ng-if='self.state.hasPasscode && !self.state.formData.showPasscodeForm')
.sk-p .sk-p
| Passcode lock is enabled. | Passcode lock is enabled.
.sk-notification.contrast .sk-notification.contrast

View File

@@ -24,7 +24,7 @@
| steps necessary with your supervision. | steps necessary with your supervision.
.sk-panel-row .sk-panel-row
.sk-panel-column .sk-panel-column
p.sk-p For more information about security updates, please visit p.sk-p For more information about account updates, please visit
a.sk-a.info( a.sk-a.info(
href='https://standardnotes.org/help/security', href='https://standardnotes.org/help/security',
rel='noopener', rel='noopener',
@@ -121,7 +121,7 @@
p.sk-p.sk-panel-row.info-i Your password has been successfully changed. p.sk-p.sk-panel-row.info-i Your password has been successfully changed.
div(ng-if='ctrl.securityUpdate') div(ng-if='ctrl.securityUpdate')
p.sk-p.sk-panel-row.info-i p.sk-p.sk-panel-row.info-i
| The security update has been successfully applied to your account. | The account update has been successfully applied to your account.
p.sk-p.sk-panel-row p.sk-p.sk-panel-row
| Please ensure you are running the latest version of Standard Notes | Please ensure you are running the latest version of Standard Notes
| on all platforms to ensure maximum compatibility. | on all platforms to ensure maximum compatibility.

View File

@@ -42,7 +42,7 @@
ng-click='ctrl.openSecurityUpdate()', ng-click='ctrl.openSecurityUpdate()',
ng-show='ctrl.securityUpdateAvailable' ng-show='ctrl.securityUpdateAvailable'
) )
span.success.sk-label Security update available. span.success.sk-label Account update available.
.sk-app-bar-item( .sk-app-bar-item(
ng-click='ctrl.clickedNewUpdateAnnouncement()', ng-click='ctrl.clickedNewUpdateAnnouncement()',
ng-show='ctrl.newUpdateAvailable == true' ng-show='ctrl.newUpdateAvailable == true'

View File

@@ -3,6 +3,8 @@
) )
lock-screen( lock-screen(
ng-if='self.state.needsUnlock' ng-if='self.state.needsUnlock'
on-value='self.state.onLockscreenValue',
puppet='self.lockScreenPuppet'
) )
#app.app( #app.app(
ng-class='self.state.appClass', ng-class='self.state.appClass',

1417
dist/javascripts/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "3.3.0", "version": "3.5.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "3.3.0", "version": "3.5.0",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"repository": { "repository": {
"type": "git", "type": "git",