Merge branch 'release/3.5.9' into develop

This commit is contained in:
Baptiste Grob
2020-11-23 17:15:08 +01:00
7 changed files with 86 additions and 30 deletions

View File

@@ -22,7 +22,6 @@ import {
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL, STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL,
STRING_UNSUPPORTED_BACKUP_FILE_VERSION STRING_UNSUPPORTED_BACKUP_FILE_VERSION
} from '@/strings'; } from '@/strings';
import { SyncOpStatus } from '@standardnotes/snjs';
import { PasswordWizardType } from '@/types'; import { PasswordWizardType } from '@/types';
import { BackupFile } from '@standardnotes/snjs'; import { BackupFile } from '@standardnotes/snjs';
import { confirmDialog, alertDialog } from '@/services/alertService'; import { confirmDialog, alertDialog } from '@/services/alertService';
@@ -67,15 +66,18 @@ type AccountMenuState = {
selectedAutoLockInterval: any; selectedAutoLockInterval: any;
showBetaWarning: boolean; showBetaWarning: boolean;
errorReportingEnabled: boolean; errorReportingEnabled: boolean;
syncInProgress: boolean;
syncError: string;
syncPercentage: string;
} }
class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> { class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
public appVersion: string public appVersion: string
/** @template */ /** @template */
syncStatus?: SyncOpStatus
private closeFunction?: () => void private closeFunction?: () => void
private removeBetaWarningListener?: IReactionDisposer private removeBetaWarningListener?: IReactionDisposer
private removeSyncObserver?: IReactionDisposer
/* @ngInject */ /* @ngInject */
constructor( constructor(
@@ -130,7 +132,14 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
$onInit() { $onInit() {
super.$onInit(); super.$onInit();
this.syncStatus = this.application!.getSyncStatus(); const sync = this.appState.sync;
this.removeSyncObserver = autorun(() => {
this.setState({
syncInProgress: sync.inProgress,
syncError: sync.errorMessage,
syncPercentage: sync.humanReadablePercentage,
});
})
this.removeBetaWarningListener = autorun(() => { this.removeBetaWarningListener = autorun(() => {
this.setState({ this.setState({
showBetaWarning: this.appState.showBetaWarning showBetaWarning: this.appState.showBetaWarning
@@ -139,6 +148,7 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
} }
deinit() { deinit() {
this.removeSyncObserver?.();
this.removeBetaWarningListener?.(); this.removeBetaWarningListener?.();
super.deinit(); super.deinit();
} }

View File

@@ -10,7 +10,8 @@ import {
SNSmartTag, SNSmartTag,
PayloadSource, PayloadSource,
DeinitSource, DeinitSource,
UuidString UuidString,
SyncOpStatus
} from '@standardnotes/snjs'; } from '@standardnotes/snjs';
import { WebApplication } from '@/ui_models/application'; import { WebApplication } from '@/ui_models/application';
import { Editor } from '@/ui_models/editor'; import { Editor } from '@/ui_models/editor';
@@ -58,6 +59,39 @@ class ActionsMenuState {
} }
} }
export class SyncState {
inProgress = false;
errorMessage?: string;
humanReadablePercentage?: string;
constructor() {
makeObservable(this, {
inProgress: observable,
errorMessage: observable,
humanReadablePercentage: observable,
update: action,
});
}
update(status: SyncOpStatus) {
this.errorMessage = status.error?.message;
this.inProgress = status.syncInProgress;
const stats = status.getStats();
const completionPercentage = stats.uploadCompletionCount === 0
? 0
: stats.uploadCompletionCount / stats.uploadTotalCount;
if (completionPercentage === 0) {
this.humanReadablePercentage = undefined;
} else {
this.humanReadablePercentage = completionPercentage.toLocaleString(
undefined,
{ style: 'percent' }
);
}
}
}
export class AppState { export class AppState {
$rootScope: ng.IRootScopeService; $rootScope: ng.IRootScopeService;
$timeout: ng.ITimeoutService; $timeout: ng.ITimeoutService;
@@ -72,7 +106,8 @@ export class AppState {
userPreferences?: SNUserPrefs; userPreferences?: SNUserPrefs;
multiEditorEnabled = false; multiEditorEnabled = false;
showBetaWarning = false; showBetaWarning = false;
actionsMenu = new ActionsMenuState(); readonly actionsMenu = new ActionsMenuState();
readonly sync = new SyncState();
/* @ngInject */ /* @ngInject */
constructor( constructor(
@@ -263,10 +298,16 @@ export class AppState {
addAppEventObserver() { addAppEventObserver() {
this.unsubApp = this.application.addEventObserver(async (eventName) => { this.unsubApp = this.application.addEventObserver(async (eventName) => {
if (eventName === ApplicationEvent.Started) { switch (eventName) {
this.locked = true; case ApplicationEvent.Started:
} else if (eventName === ApplicationEvent.Launched) { this.locked = true;
this.locked = false; break;
case ApplicationEvent.Launched:
this.locked = false;
break;
case ApplicationEvent.SyncStatusChanged:
this.sync.update(this.application.getSyncStatus());
break;
} }
}); });
} }

View File

@@ -34,6 +34,12 @@
margin-left: 0.3rem; margin-left: 0.3rem;
} }
.sk-horizontal-group {
display: flex;
flex-direction: row;
align-items: center;
}
.sk-panel-section { .sk-panel-section {
&:last-child { &:last-child {
padding-bottom: 1rem; padding-bottom: 1rem;

View File

@@ -136,11 +136,11 @@
!self.state.formData.showRegister` !self.state.formData.showRegister`
) )
.sk-panel-section(ng-if='self.state.user') .sk-panel-section(ng-if='self.state.user')
.sk-notification.danger(ng-if='self.syncStatus.error') .sk-notification.danger(ng-if='self.state.syncError')
.sk-notification-title Sync Unreachable .sk-notification-title Sync Unreachable
.sk-notification-text .sk-notification-text
| Hmm...we can't seem to sync your account. | Hmm...we can't seem to sync your account.
| The reason: {{self.syncStatus.error.message}} | The reason: {{self.state.syncError}}
a.sk-a.info-contrast.sk-bold.sk-panel-row( a.sk-a.info-contrast.sk-bold.sk-panel-row(
href='https://standardnotes.org/help', href='https://standardnotes.org/help',
rel='noopener', rel='noopener',
@@ -150,17 +150,16 @@
.sk-panel-column .sk-panel-column
.sk-h1.sk-bold.wrap {{self.state.user.email}} .sk-h1.sk-bold.wrap {{self.state.user.email}}
.sk-subtitle.subtle.normal {{self.state.server}} .sk-subtitle.subtle.normal {{self.state.server}}
.sk-horizontal-group( .sk-horizontal-group(
delay='1000', delay='1000',
delay-hide='true', delay-hide='true',
show='self.syncStatus.syncOpInProgress || self.syncStatus.needsMoreSync' show='self.state.syncInProgress'
) )
.sk-spinner.small.info .sk-spinner.small.info
.sk-sublabel .sk-sublabel
| {{"Syncing" + (self.syncStatus.total > 0 ? ":" : "")}} | Syncing
span( span(ng-if='self.state.syncPercentage')
ng-if='self.syncStatus.total > 0' | ({{self.state.syncPercentage}})
) {{self.syncStatus.current}}/{{self.syncStatus.total}}
.sk-panel-row .sk-panel-row
a.sk-a.info.sk-panel-row.condensed( a.sk-a.info.sk-panel-row.condensed(
ng-click="self.openPasswordWizard()" ng-click="self.openPasswordWizard()"

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "3.5.9-beta01", "version": "3.5.9",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -2574,9 +2574,9 @@
} }
}, },
"@standardnotes/snjs": { "@standardnotes/snjs": {
"version": "2.0.7", "version": "2.0.11",
"resolved": "https://registry.npmjs.org/@standardnotes/snjs/-/snjs-2.0.7.tgz", "resolved": "https://registry.npmjs.org/@standardnotes/snjs/-/snjs-2.0.11.tgz",
"integrity": "sha512-S9h+ryQ225ekvCDwX4wFk7duic+j6644indtSLCiODo1SMflk8EQa7Q6Ier5lvBdUZJNxvZsN51iAgmIbT5BCQ==", "integrity": "sha512-5Ymdd8mez2DNFu4fRmbpZ4BXeFmFhiIFlwZURp8ZM+zqJFRwCo5SXu813DghAU3x51+cPwBMR/3kwuh9GouIpQ==",
"requires": { "requires": {
"@standardnotes/sncrypto-common": "^1.2.9" "@standardnotes/sncrypto-common": "^1.2.9"
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "3.5.9-beta01", "version": "3.5.9",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -71,7 +71,7 @@
"dependencies": { "dependencies": {
"@bugsnag/js": "^7.5.1", "@bugsnag/js": "^7.5.1",
"@standardnotes/sncrypto-web": "^1.2.9", "@standardnotes/sncrypto-web": "^1.2.9",
"@standardnotes/snjs": "^2.0.7", "@standardnotes/snjs": "^2.0.11",
"mobx": "^6.0.1" "mobx": "^6.0.1"
} }
} }

View File

@@ -3,12 +3,12 @@
"short_name": "", "short_name": "",
"icons": [ "icons": [
{ {
"src": "favicon/android-chrome-192x192.png", "src": "android-chrome-192x192.png",
"sizes": "192x192", "sizes": "192x192",
"type": "image/png" "type": "image/png"
}, },
{ {
"src": "favicon/android-chrome-512x512.png", "src": "android-chrome-512x512.png",
"sizes": "512x512", "sizes": "512x512",
"type": "image/png" "type": "image/png"
} }