diff --git a/app/assets/javascripts/services/statusManager.ts b/app/assets/javascripts/services/statusManager.ts index c717dc2cc..d46ea1667 100644 --- a/app/assets/javascripts/services/statusManager.ts +++ b/app/assets/javascripts/services/statusManager.ts @@ -8,20 +8,13 @@ export class StatusManager { private statuses: FooterStatus[] = [] private observers: StatusCallback[] = [] - statusFromString(string: string) { - return {string: string}; - } - replaceStatusWithString(status: FooterStatus, string: string) { this.removeStatus(status); return this.addStatusFromString(string); } addStatusFromString(string: string) { - return this.addStatus(this.statusFromString(string)); - } - - addStatus(status: FooterStatus) { + const status = { string }; this.statuses.push(status); this.notifyObservers(); return status; @@ -33,7 +26,20 @@ export class StatusManager { return undefined; } - getStatusString() { + addStatusObserver(callback: StatusCallback) { + this.observers.push(callback); + return () => { + removeFromArray(this.observers, callback); + } + } + + private notifyObservers() { + for(const observer of this.observers) { + observer(this.getStatusString()); + } + } + + private getStatusString() { let result = ''; this.statuses.forEach((status, index) => { if(index > 0) { @@ -45,16 +51,4 @@ export class StatusManager { return result; } - notifyObservers() { - for(const observer of this.observers) { - observer(this.getStatusString()); - } - } - - addStatusObserver(callback: StatusCallback) { - this.observers.push(callback); - return () => { - removeFromArray(this.observers, callback); - } - } } diff --git a/app/assets/javascripts/views/application/application_view.ts b/app/assets/javascripts/views/application/application_view.ts index 020fe30a2..4c6752f86 100644 --- a/app/assets/javascripts/views/application/application_view.ts +++ b/app/assets/javascripts/views/application/application_view.ts @@ -118,7 +118,7 @@ class ApplicationViewCtrl extends PureViewCtrl { if (!this.completedInitialSync) { this.syncStatus = this.application!.getStatusService().replaceStatusWithString( this.syncStatus, - "Syncing..." + "Syncing…" ); } } else if (eventName === ApplicationEvent.CompletedFullSync) { @@ -203,9 +203,18 @@ class ApplicationViewCtrl extends PureViewCtrl { this.syncStatus = this.application!.getStatusService().removeStatus(this.syncStatus); }, 2000); } else if (stats.uploadTotalCount > 20) { + const completionPercentage = stats.uploadCompletionCount === 0 + ? 0 + : stats.uploadCompletionCount / stats.uploadTotalCount; + + const stringPercentage = completionPercentage.toLocaleString( + undefined, + { style: 'percent' } + ); + this.uploadSyncStatus = this.application!.getStatusService().replaceStatusWithString( this.uploadSyncStatus, - `Syncing ${stats.uploadCompletionCount}/${stats.uploadTotalCount} items...` + `Syncing ${stats.uploadTotalCount} items (${stringPercentage} complete)`, ); } else { if (this.syncStatus) { diff --git a/package-lock.json b/package-lock.json index 142ee29a2..6408fac09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10956,8 +10956,8 @@ "from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad" }, "snjs": { - "version": "github:standardnotes/snjs#9003251047822f4353bcb83ec4dca59d9aebb301", - "from": "github:standardnotes/snjs#9003251047822f4353bcb83ec4dca59d9aebb301" + "version": "github:standardnotes/snjs#f922ede72a3e90984605048854dc20db8a88c790", + "from": "github:standardnotes/snjs#f922ede72a3e90984605048854dc20db8a88c790" }, "sockjs": { "version": "0.3.20", diff --git a/package.json b/package.json index 5b99ed4cd..e758a2809 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,6 @@ }, "dependencies": { "sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad", - "snjs": "github:standardnotes/snjs#9003251047822f4353bcb83ec4dca59d9aebb301" + "snjs": "github:standardnotes/snjs#f922ede72a3e90984605048854dc20db8a88c790" } }