This commit is contained in:
Mo Bitar
2020-02-11 11:17:03 -06:00
parent 1497048c72
commit d91d141417
12 changed files with 253 additions and 349 deletions

View File

@@ -112,17 +112,13 @@ class EditorCtrl extends PureCtrl {
return; return;
} }
if (eventName === ApplicationEvents.HighLatencySync) { if (eventName === ApplicationEvents.HighLatencySync) {
this.setState({ this.setState({ syncTakingTooLong: true });
syncTakingTooLong: true
});
} else if (eventName === ApplicationEvents.CompletedSync) { } else if (eventName === ApplicationEvents.CompletedSync) {
this.setState({ this.setState({ syncTakingTooLong: false });
syncTakingTooLong: false
});
if (this.state.note.dirty) { if (this.state.note.dirty) {
/** if we're still dirty, don't change status, a sync is likely upcoming. */ /** if we're still dirty, don't change status, a sync is likely upcoming. */
} else { } else {
const saved = this.state.note.updated_at > this.state.note.lastSyncBegan; const saved = this.state.note.lastSyncEnd > this.state.note.lastSyncBegan;
const isInErrorState = this.state.saveError; const isInErrorState = this.state.saveError;
if (isInErrorState || saved) { if (isInErrorState || saved) {
this.showAllChangesSavedStatus(); this.showAllChangesSavedStatus();

View File

@@ -59,7 +59,6 @@ class FooterCtrl extends PureCtrl {
}); });
this.user = this.application.getUser(); this.user = this.application.getUser();
this.updateOfflineStatus(); this.updateOfflineStatus();
this.addAppEventObserver();
this.findErrors(); this.findErrors();
this.streamItems(); this.streamItems();
this.registerComponentHandler(); this.registerComponentHandler();
@@ -111,15 +110,14 @@ class FooterCtrl extends PureCtrl {
/** @override */ /** @override */
onApplicationEvent(eventName) { onApplicationEvent(eventName) {
if (eventName === ApplicationEvents.LoadedLocalData) { if (eventName === ApplicationEvents.EnteredOutOfSync) {
if (this.offline && this.application.getNoteCount() === 0) {
this.showAccountMenu = true;
}
} else if (eventName === ApplicationEvents.EnteredOutOfSync) {
this.outOfSync = true; this.outOfSync = true;
} else if (eventName === ApplicationEvents.ExitedOutOfSync) { } else if (eventName === ApplicationEvents.ExitedOutOfSync) {
this.outOfSync = false; this.outOfSync = false;
} else if (eventName === ApplicationEvents.CompletedSync) { } else if (eventName === ApplicationEvents.CompletedSync) {
if (this.offline && this.application.getNoteCount() === 0) {
this.showAccountMenu = true;
}
this.syncUpdated(); this.syncUpdated();
this.findErrors(); this.findErrors();
this.updateOfflineStatus(); this.updateOfflineStatus();

View File

@@ -113,6 +113,9 @@ class NotesCtrl extends PureCtrl {
this.createDummyOnSynCompletionIfNoNotes = true; this.createDummyOnSynCompletionIfNoNotes = true;
} }
} else if (eventName === ApplicationEvents.CompletedSync) { } else if (eventName === ApplicationEvents.CompletedSync) {
if (this.state.notes.length === 0) {
this.createNewNote();
}
if (this.createDummyOnSynCompletionIfNoNotes && this.state.notes.length === 0) { if (this.createDummyOnSynCompletionIfNoNotes && this.state.notes.length === 0) {
this.createDummyOnSynCompletionIfNoNotes = false; this.createDummyOnSynCompletionIfNoNotes = false;
this.createNewNote(); this.createNewNote();

View File

@@ -37,7 +37,7 @@ class RootCtrl extends PureCtrl {
this.themeManager = themeManager; this.themeManager = themeManager;
this.platformString = getPlatformString(); this.platformString = getPlatformString();
this.state = { this.state = {
needsUnlock: true, ready: false,
appClass: '' appClass: ''
}; };
this.loadApplication(); this.loadApplication();
@@ -86,6 +86,7 @@ class RootCtrl extends PureCtrl {
} }
}); });
await this.application.launch(); await this.application.launch();
this.setState({ ready: true });
// this.addSyncStatusObserver(); // this.addSyncStatusObserver();
// this.addSyncEventHandler(); // this.addSyncEventHandler();
} }

View File

@@ -53,7 +53,9 @@ class AccountMenuCtrl extends PureCtrl {
passcodeAutoLockOptions: this.lockManager.getAutoLockIntervalOptions(), passcodeAutoLockOptions: this.lockManager.getAutoLockIntervalOptions(),
formData: { formData: {
mergeLocal: true, mergeLocal: true,
ephemeral: false ephemeral: false,
email: "b@bitar.io",
user_password: "password"
}, },
mutable: {} mutable: {}
}; };
@@ -182,7 +184,7 @@ class AccountMenuCtrl extends PureCtrl {
password: this.state.formData.user_password, password: this.state.formData.user_password,
strict: this.state.formData.strictSignin, strict: this.state.formData.strictSignin,
ephemeral: this.state.formData.ephemeral, ephemeral: this.state.formData.ephemeral,
mfaKeyPath: this.state.formData.mfa.payload.mfa_key, mfaKeyPath: this.state.formData.mfa && this.state.formData.mfa.payload.mfa_key,
mfaCode: this.state.formData.userMfaCode, mfaCode: this.state.formData.userMfaCode,
mergeLocal: this.state.formData.mergeLocal mergeLocal: this.state.formData.mergeLocal
}); });
@@ -314,7 +316,7 @@ class AccountMenuCtrl extends PureCtrl {
* https://github.com/standardnotes/desktop/issues/131 * https://github.com/standardnotes/desktop/issues/131
*/ */
async rewriteDatabase({ alternateUuids } = {}) { async rewriteDatabase({ alternateUuids } = {}) {
await this.application.destroyDatabase(); await this.application.clearDatabase();
await this.application.markAllItemsAsNeedingSync({ alternateUuids }); await this.application.markAllItemsAsNeedingSync({ alternateUuids });
} }
@@ -324,7 +326,6 @@ class AccountMenuCtrl extends PureCtrl {
destructive: true, destructive: true,
onConfirm: async () => { onConfirm: async () => {
await this.application.signOut(); await this.application.signOut();
window.location.reload();
} }
}); });
} }

View File

@@ -4,11 +4,7 @@ import { isNullOrUndefined } from '../../utils';
const DEFAULT_CONTINUE_TITLE = "Continue"; const DEFAULT_CONTINUE_TITLE = "Continue";
const Steps = { const Steps = {
IntroStep: 0,
BackupStep: 1,
SignoutStep: 2,
PasswordStep: 3, PasswordStep: 3,
SyncStep: 4,
FinishStep: 5 FinishStep: 5
}; };
@@ -17,18 +13,15 @@ class PasswordWizardCtrl {
constructor( constructor(
$element, $element,
$scope, $scope,
$timeout, $timeout
archiveManager
) { ) {
this.$element = $element; this.$element = $element;
this.$timeout = $timeout; this.$timeout = $timeout;
this.$scope = $scope; this.$scope = $scope;
this.archiveManager = archiveManager;
this.registerWindowUnloadStopper(); this.registerWindowUnloadStopper();
} }
$onInit() { $onInit() {
this.syncStatus = this.application.getSyncStatus();
this.formData = {}; this.formData = {};
this.configureDefaults(); this.configureDefaults();
} }
@@ -57,18 +50,12 @@ class PasswordWizardCtrl {
titleForStep(step) { titleForStep(step) {
switch (step) { switch (step) {
case Steps.BackupStep:
return "Download a backup of your data";
case Steps.SignoutStep:
return "Sign out of all your devices";
case Steps.PasswordStep: case Steps.PasswordStep:
return this.changePassword return this.changePassword
? "Password information" ? "Password information"
: "Enter your current password"; : "Enter your current password";
case Steps.SyncStep:
return "Encrypt and sync data with new keys";
case Steps.FinishStep: case Steps.FinishStep:
return "Sign back in to your devices"; return "Success";
default: default:
return null; return null;
} }
@@ -112,9 +99,7 @@ class PasswordWizardCtrl {
} }
async initializeStep(step) { async initializeStep(step) {
if (step === Steps.SyncStep) { if (step === Steps.FinishStep) {
await this.initializeSyncingStep();
} else if (step === Steps.FinishStep) {
this.continueTitle = "Finish"; this.continueTitle = "Finish";
} }
} }
@@ -123,11 +108,10 @@ class PasswordWizardCtrl {
this.lockContinue = true; this.lockContinue = true;
this.formData.status = "Processing encryption keys..."; this.formData.status = "Processing encryption keys...";
this.formData.processing = true; this.formData.processing = true;
const passwordSuccess = await this.processPasswordChange(); const passwordSuccess = await this.processPasswordChange();
this.formData.statusError = !passwordSuccess; this.formData.statusError = !passwordSuccess;
this.formData.processing = passwordSuccess; this.formData.processing = passwordSuccess;
if(!passwordSuccess) { if (!passwordSuccess) {
this.formData.status = "Unable to process your password. Please try again."; this.formData.status = "Unable to process your password. Please try again.";
return; return;
} }
@@ -207,10 +191,6 @@ class PasswordWizardCtrl {
} }
} }
downloadBackup(encrypted) {
this.archiveManager.downloadBackup(encrypted);
}
dismiss() { dismiss() {
if (this.lockContinue) { if (this.lockContinue) {
this.application.alertManager.alert({ this.application.alertManager.alert({

View File

@@ -1,6 +1,5 @@
import { isDesktopApplication, dictToArray } from '@/utils'; import { isDesktopApplication, dictToArray } from '@/utils';
import { SFPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs'; import { SFPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs';
import { AppStateEvents } from '@/state';
const STREAM_ITEMS_PERMISSION = 'stream-items'; const STREAM_ITEMS_PERMISSION = 'stream-items';
@@ -11,18 +10,29 @@ export class NativeExtManager {
this.application = application; this.application = application;
this.extManagerId = 'org.standardnotes.extensions-manager'; this.extManagerId = 'org.standardnotes.extensions-manager';
this.batchManagerId = 'org.standardnotes.batch-manager'; this.batchManagerId = 'org.standardnotes.batch-manager';
this.systemExtensions = [];
this.resolveExtensionsManager();
this.resolveBatchManager();
application.onUnlock(() => { application.onUnlock(() => {
this.resolveExtensionsManager(); this.reload();
this.resolveBatchManager(); this.streamChanges();
}); });
} }
isSystemExtension(extension) { isSystemExtension(extension) {
return this.systemExtensions.includes(extension.uuid); return this.nativeExtIds.includes(extension.uuid);
}
streamChanges() {
this.application.streamItems({
contentType: ContentTypes.Component,
stream: () => {
this.reload();
}
});
}
reload() {
this.nativeExtIds = [];
// this.resolveExtensionsManager();
// this.resolveBatchManager();
} }
extensionsManagerTemplatePayload() { extensionsManagerTemplatePayload() {
@@ -76,7 +86,7 @@ export class NativeExtManager {
predicate: predicate, predicate: predicate,
createPayload: this.extensionsManagerTemplatePayload() createPayload: this.extensionsManagerTemplatePayload()
}); });
this.systemExtensions.push(extensionsManager.uuid); this.nativeExtIds.push(extensionsManager.uuid);
let needsSync = false; let needsSync = false;
if (isDesktopApplication()) { if (isDesktopApplication()) {
if (!extensionsManager.local_url) { if (!extensionsManager.local_url) {
@@ -144,7 +154,7 @@ export class NativeExtManager {
predicate: predicate, predicate: predicate,
createPayload: this.batchManagerTemplatePayload() createPayload: this.batchManagerTemplatePayload()
}); });
this.systemExtensions.push(batchManager.uuid); this.nativeExtIds.push(batchManager.uuid);
let needsSync = false; let needsSync = false;
if (isDesktopApplication()) { if (isDesktopApplication()) {
if (!batchManager.local_url) { if (!batchManager.local_url) {

View File

@@ -1,4 +1,4 @@
import { SFPredicate, CreateMaxPayloadFromAnyObject } from 'snjs'; import { SFPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs';
export const PrefKeys = { export const PrefKeys = {
TagsPanelWidth: 'tagsPanelWidth', TagsPanelWidth: 'tagsPanelWidth',
@@ -33,24 +33,26 @@ export class PreferencesManager {
streamPreferences() { streamPreferences() {
this.application.streamItems({ this.application.streamItems({
contentType: 'SN|UserPreferences', contentType: ContentTypes.UserPrefs,
stream: () => { stream: () => {
this.preferencesDidChange(); this.loadSingleton();
} }
}); });
} }
async loadSingleton() { async loadSingleton() {
const contentType = 'SN|UserPreferences'; const contentType = ContentTypes.UserPrefs;
const predicate = new SFPredicate('content_type', '=', contentType); const predicate = new SFPredicate('content_type', '=', contentType);
this.userPreferences = await this.application.singletonManager.findOrCreateSingleton({ this.userPreferences = await this.application.singletonManager.findOrCreateSingleton({
predicate: predicate, predicate: predicate,
createPayload: CreateMaxPayloadFromAnyObject({ createPayload: CreateMaxPayloadFromAnyObject({
object: { object: {
content_type: contentType content_type: contentType,
content: {}
} }
}) })
}); });
this.preferencesDidChange();
} }
preferencesDidChange() { preferencesDidChange() {

View File

@@ -8,72 +8,7 @@
.sk-panel-header-title {{ctrl.title}} .sk-panel-header-title {{ctrl.title}}
a.sk-a.info.close-button(ng-click='ctrl.dismiss()') Close a.sk-a.info.close-button(ng-click='ctrl.dismiss()') Close
.sk-panel-content .sk-panel-content
div(ng-if='ctrl.step == 0')
div(ng-if='ctrl.changePassword')
p.sk-p.sk-panel-row
| Changing your password involves changing your encryption key,
| which requires your data to be re-encrypted and synced.
| If you have many items, syncing your data can take several minutes.
p.sk-p.sk-panel-row
| You must keep the application window open during this process.
div(ng-if='ctrl.securityUpdate')
p.sk-p.sk-panel-row
| A new update is available for your account. Updates address
| improvements and enhancements to our security specification.
| This process will guide you through the update, and perform the
| steps necessary with your supervision.
.sk-panel-row
.sk-panel-column
p.sk-p For more information about account updates, please visit
a.sk-a.info(
href='https://standardnotes.org/help/security',
rel='noopener',
target='_blank'
) standardnotes.org/help/security.
p.sk-panel-row.sk-p
.info Press Continue to proceed.
p
.sk-panel-section(ng-if='ctrl.step > 0')
.sk-panel-section-title Step {{ctrl.step}} — {{ctrl.titleForStep(ctrl.step)}}
div(ng-if='ctrl.step == 1')
p.sk-panel-row.sk-p
| As a result of this process, the entirety of your data will be
| re-encrypted and synced to your account. This is a generally safe
| process, but unforeseen factors like poor network connectivity or a
| sudden shutdown of your computer may cause this process to fail. It's
| best to be on the safe side before large operations such as this one.
.sk-panel-row
.sk-panel-row
.sk-button-group
.sk-button.info(ng-click='ctrl.downloadBackup(true)')
.sk-label Download Encrypted Backup
.sk-button.info(ng-click='ctrl.downloadBackup(false)')
.sk-label Download Decrypted Backup
div(ng-if='ctrl.step == 2')
p.sk-p.sk-panel-row
| As a result of this process, your encryption keys will change. Any
| device on which you use Standard Notes will need to end its session.
| After this process completes, you will be asked to sign back in.
p.sk-p.bold.sk-panel-row.info-i
| Please sign out of all applications (excluding this one), including:
ul
li.sk-p Desktop
li.sk-p Web (Chrome, Firefox, Safari)
li.sk-p Mobile (iOS and Android)
p.sk-p.sk-panel-row
| If you do not currently have access to a device you're signed in on,
| you may proceed, but must make signing out and back in the first step
| upon gaining access to that device.
p.sk-p.sk-panel-row
| Press Continue only when you have
| completed signing out of all your devices.
div(ng-if='ctrl.step == 3') div(ng-if='ctrl.step == 3')
div(ng-if='ctrl.changePassword')
div(ng-if='ctrl.securityUpdate')
p.sk-panel-row
| Enter your current password. We'll run this through our encryption
| scheme to generate strong new encryption keys.
.sk-panel-row
.sk-panel-row .sk-panel-row
.sk-panel-column.stretch .sk-panel-column.stretch
form.sk-panel-form form.sk-panel-form
@@ -96,26 +31,6 @@
placeholder='Confirm New Password', placeholder='Confirm New Password',
type='password' type='password'
) )
div(ng-if='ctrl.step == 4')
p.sk-panel-row
| Your data is being re-encrypted with your new
| keys and synced to your account.
p.sk-panel-row.danger(ng-if='ctrl.lockContinue')
| Do not close this window until this process completes.
.sk-panel-row
.sk-panel-column
.sk-spinner.small.inline.info.mr-5(ng-if='ctrl.formData.processing')
.inline.bold(
ng-class="{'info' : !ctrl.formData.statusError, 'error' : ctrl.formData.statusError}"
)
| {{ctrl.formData.status}}
.sk-panel-column(
delay='1000',
delay-hide='true',
show='ctrl.syncStatus.syncOpInProgress || ctrl.syncStatus.needsMoreSync'
)
p.info
| Syncing {{ctrl.syncStatus.current}}/{{ctrl.syncStatus.total}}
div(ng-if='ctrl.step == 5') div(ng-if='ctrl.step == 5')
div(ng-if='ctrl.changePassword') div(ng-if='ctrl.changePassword')
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.
@@ -125,8 +40,6 @@
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.
p.sk-p.sk-panel-row
| You may now sign back in on all your devices and close this window.
.sk-panel-footer .sk-panel-footer
.empty .empty
a.sk-a.info.right( a.sk-a.info.right(

View File

@@ -1,5 +1,6 @@
.main-ui-view( .main-ui-view(
ng-class='self.platformString' ng-class='self.platformString'
ng-if='self.state.ready'
) )
lock-screen( lock-screen(
ng-if='self.state.needsUnlock' ng-if='self.state.needsUnlock'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long