WIP
This commit is contained in:
@@ -12,8 +12,8 @@ import { WebDeviceInterface } from '@/web_device_interface';
|
||||
|
||||
export class Application extends SNApplication {
|
||||
/* @ngInject */
|
||||
constructor($compile, $rootScope) {
|
||||
const deviceInterface = new WebDeviceInterface();
|
||||
constructor($compile, $timeout, $rootScope) {
|
||||
const deviceInterface = new WebDeviceInterface({timeout: $timeout});
|
||||
super({
|
||||
environment: Environments.Web,
|
||||
platform: platformFromString(getPlatformString()),
|
||||
|
||||
@@ -701,7 +701,7 @@ class EditorCtrl extends PureCtrl {
|
||||
this.saveTags({ strings: strings });
|
||||
}
|
||||
|
||||
saveTags({ strings } = {}) {
|
||||
async saveTags({ strings } = {}) {
|
||||
if (!strings && this.state.mutable.tagsString === this.state.note.tagsString()) {
|
||||
return;
|
||||
}
|
||||
@@ -732,7 +732,7 @@ class EditorCtrl extends PureCtrl {
|
||||
);
|
||||
if (!existingRelationship) {
|
||||
tags.push(
|
||||
this.application.findOrCreateTag({ title: tagString })
|
||||
await this.application.findOrCreateTag({ title: tagString })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ class LockScreenCtrl {
|
||||
this.addDestroyHandler();
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.puppet.focusInput = () => {
|
||||
this.passcodeInput.focus();
|
||||
};
|
||||
}
|
||||
|
||||
get passcodeInput() {
|
||||
return document.getElementById(
|
||||
ELEMENT_ID_PASSCODE_INPUT
|
||||
@@ -49,15 +55,7 @@ class LockScreenCtrl {
|
||||
return;
|
||||
}
|
||||
this.passcodeInput.blur();
|
||||
const success = await this.onValue()(this.formData.passcode);
|
||||
if(!success) {
|
||||
this.application.alertManager.alert({
|
||||
text: "Invalid passcode. Please try again.",
|
||||
onClose: () => {
|
||||
this.passcodeInput.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.onValue()(this.formData.passcode);
|
||||
}
|
||||
|
||||
forgotPasscode() {
|
||||
@@ -85,6 +83,7 @@ export class LockScreen {
|
||||
this.bindToController = true;
|
||||
this.scope = {
|
||||
onValue: '&',
|
||||
puppet: '='
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import { Challenges } from 'snjs';
|
||||
import { Challenges, ChallengeResponse } from 'snjs';
|
||||
import { getPlatformString } from '@/utils';
|
||||
import template from '%/root.pug';
|
||||
import { AppStateEvents } from '@/state';
|
||||
@@ -46,20 +45,48 @@ class RootCtrl extends PureCtrl {
|
||||
this.loadApplication();
|
||||
this.addAppStateObserver();
|
||||
this.addDragDropHandlers();
|
||||
|
||||
|
||||
application.onReady(() => {
|
||||
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() {
|
||||
await this.application.prepareForLaunch({
|
||||
callbacks: {
|
||||
authChallengeResponses: async (challenges) => {
|
||||
console.log("Needs challenge repsonses", challenges);
|
||||
requiresChallengeResponses: async (challenges) => {
|
||||
if (challenges.includes(Challenges.LocalPasscode)) {
|
||||
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 () => {
|
||||
await this.appState.setApplicationReady();
|
||||
|
||||
@@ -36,6 +36,10 @@ class TagsPanelCtrl extends PureCtrl {
|
||||
});
|
||||
this.selectTag(smartTags[0]);
|
||||
});
|
||||
|
||||
application.onSync(() => {
|
||||
this.reloadNoteCounts();
|
||||
});
|
||||
}
|
||||
|
||||
beginStreamingItems() {
|
||||
|
||||
@@ -59,19 +59,27 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
},
|
||||
mutable: {}
|
||||
};
|
||||
application.onReady(() => {
|
||||
this.setState({
|
||||
user: this.application.getUser(),
|
||||
canAddPasscode: !this.application.isEphemeralSession(),
|
||||
});
|
||||
application.onReady(async () => {
|
||||
this.setState(await this.refreshedCredentialState());
|
||||
this.loadHost();
|
||||
this.checkForSecurityUpdate();
|
||||
this.reloadAutoLockInterval();
|
||||
this.loadBackupsAvailability();
|
||||
});
|
||||
application.onCredentialChange(async () => {
|
||||
this.setState(await this.refreshedCredentialState());
|
||||
});
|
||||
this.syncStatus = this.application.getSyncStatus();
|
||||
}
|
||||
|
||||
async refreshedCredentialState() {
|
||||
return {
|
||||
user: this.application.getUser(),
|
||||
canAddPasscode: !this.application.isEphemeralSession(),
|
||||
hasPasscode: await this.application.hasPasscode()
|
||||
};
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.initProps({
|
||||
closeFunction: this.closeFunction
|
||||
@@ -473,10 +481,6 @@ class AccountMenuCtrl extends PureCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
hasPasscode() {
|
||||
return this.application.hasPasscode();
|
||||
}
|
||||
|
||||
addPasscodeClicked() {
|
||||
this.setFormDataState({
|
||||
showPasscodeForm: true
|
||||
|
||||
@@ -38,7 +38,7 @@ class PasswordWizardCtrl {
|
||||
this.title = "Change Password";
|
||||
this.changePassword = true;
|
||||
} else if (this.type === 'upgrade-security') {
|
||||
this.title = "Security Update";
|
||||
this.title = "Account Update";
|
||||
this.securityUpdate = true;
|
||||
}
|
||||
this.continueTitle = DEFAULT_CONTINUE_TITLE;
|
||||
@@ -135,7 +135,7 @@ class PasswordWizardCtrl {
|
||||
if (this.changePassword) {
|
||||
this.formData.status = "Successfully changed password.";
|
||||
} else if (this.securityUpdate) {
|
||||
this.formData.status = "Successfully performed security update.";
|
||||
this.formData.status = "Successfully performed account update.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@ class RevisionPreviewModalCtrl {
|
||||
constructor(
|
||||
$element,
|
||||
$scope,
|
||||
$timeout
|
||||
$timeout,
|
||||
application
|
||||
) {
|
||||
this.$element = $element;
|
||||
this.$scope = $scope;
|
||||
this.$timeout = $timeout;
|
||||
this.application = application;
|
||||
this.configure();
|
||||
$scope.$on('$destroy', () => {
|
||||
if (this.identifier) {
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
/* eslint-disable prefer-promise-reject-errors */
|
||||
import { SNAlertManager } from 'snjs';
|
||||
import { SKAlert } from 'sn-stylekit';
|
||||
|
||||
export class AlertManager extends SNAlertManager {
|
||||
/* @ngInject */
|
||||
constructor($timeout) {
|
||||
super();
|
||||
this.$timeout = $timeout;
|
||||
}
|
||||
|
||||
async alert({
|
||||
title,
|
||||
text,
|
||||
@@ -21,7 +16,7 @@ export class AlertManager extends SNAlertManager {
|
||||
style: "neutral",
|
||||
action: async () => {
|
||||
if(onClose) {
|
||||
this.$timeout(onClose);
|
||||
this.deviceInterface.timeout(onClose);
|
||||
}
|
||||
resolve(true);
|
||||
}
|
||||
@@ -48,7 +43,7 @@ export class AlertManager extends SNAlertManager {
|
||||
style: "neutral",
|
||||
action: async () => {
|
||||
if(onCancel) {
|
||||
this.$timeout(onCancel);
|
||||
this.deviceInterface.timeout(onCancel);
|
||||
}
|
||||
reject(false);
|
||||
}
|
||||
@@ -58,7 +53,7 @@ export class AlertManager extends SNAlertManager {
|
||||
style: destructive ? "danger" : "info",
|
||||
action: async () => {
|
||||
if(onConfirm) {
|
||||
this.$timeout(onConfirm);
|
||||
this.deviceInterface.timeout(onConfirm);
|
||||
}
|
||||
resolve(true);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,11 @@ export class GodService {
|
||||
if (this.application.noAccount()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const latest = await this.application.getUserVersion();
|
||||
const updateAvailable = await this.protocolVersion() !== latest;
|
||||
const updateAvailable = await this.application.protocolService.upgradeAvailable();
|
||||
if (updateAvailable !== this.securityUpdateAvailable) {
|
||||
this.securityUpdateAvailable = updateAvailable;
|
||||
this.$rootScope.$broadcast("security-update-status-changed");
|
||||
}
|
||||
|
||||
return this.securityUpdateAvailable;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ export class WebDeviceInterface extends DeviceInterface {
|
||||
|
||||
constructor({
|
||||
namespace,
|
||||
timeout
|
||||
} = {}) {
|
||||
super({
|
||||
namespace,
|
||||
timeout: setTimeout.bind(getGlobalScope()),
|
||||
timeout: timeout || setTimeout.bind(getGlobalScope()),
|
||||
interval: setInterval.bind(getGlobalScope())
|
||||
});
|
||||
this.createDatabase();
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
ng-if='self.state.securityUpdateAvailable'
|
||||
)
|
||||
.inline.sk-circle.small.success.mr-8
|
||||
.inline Security Update Available
|
||||
.inline Account Update Available
|
||||
.sk-panel-section
|
||||
.sk-panel-section-title Encryption
|
||||
.sk-panel-section-subtitle.info(ng-if='self.state.encryptionEnabled')
|
||||
@@ -210,7 +210,7 @@
|
||||
| {{self.state.encryptionStatusString}}
|
||||
.sk-panel-section
|
||||
.sk-panel-section-title Passcode Lock
|
||||
div(ng-if='!self.hasPasscode()')
|
||||
div(ng-if='!self.state.hasPasscode')
|
||||
div(ng-if='self.state.canAddPasscode')
|
||||
.sk-panel-row(ng-if='!self.state.formData.showPasscodeForm')
|
||||
.sk-button.info(
|
||||
@@ -247,7 +247,7 @@
|
||||
a.neutral.sk-a.sk-panel-row(
|
||||
ng-click='self.state.formData.showPasscodeForm = false'
|
||||
) Cancel
|
||||
div(ng-if='self.hasPasscode() && !self.state.formData.showPasscodeForm')
|
||||
div(ng-if='self.state.hasPasscode && !self.state.formData.showPasscodeForm')
|
||||
.sk-p
|
||||
| Passcode lock is enabled.
|
||||
.sk-notification.contrast
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
| steps necessary with your supervision.
|
||||
.sk-panel-row
|
||||
.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(
|
||||
href='https://standardnotes.org/help/security',
|
||||
rel='noopener',
|
||||
@@ -121,7 +121,7 @@
|
||||
p.sk-p.sk-panel-row.info-i Your password has been successfully changed.
|
||||
div(ng-if='ctrl.securityUpdate')
|
||||
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
|
||||
| Please ensure you are running the latest version of Standard Notes
|
||||
| on all platforms to ensure maximum compatibility.
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
ng-click='ctrl.openSecurityUpdate()',
|
||||
ng-show='ctrl.securityUpdateAvailable'
|
||||
)
|
||||
span.success.sk-label Security update available.
|
||||
span.success.sk-label Account update available.
|
||||
.sk-app-bar-item(
|
||||
ng-click='ctrl.clickedNewUpdateAnnouncement()',
|
||||
ng-show='ctrl.newUpdateAvailable == true'
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
)
|
||||
lock-screen(
|
||||
ng-if='self.state.needsUnlock'
|
||||
on-value='self.state.onLockscreenValue',
|
||||
puppet='self.lockScreenPuppet'
|
||||
)
|
||||
#app.app(
|
||||
ng-class='self.state.appClass',
|
||||
|
||||
1417
dist/javascripts/app.js
vendored
1417
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "standard-notes-web",
|
||||
"version": "3.3.0",
|
||||
"version": "3.5.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "standard-notes-web",
|
||||
"version": "3.3.0",
|
||||
"version": "3.5.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user