From 5c7bc32306ab7733c9fcf1c88dea5fe99d1d7412 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Tue, 18 Aug 2020 18:14:24 +0200 Subject: [PATCH] style: remake updateUI into flushUI --- app/assets/javascripts/views/abstract/pure_view_ctrl.ts | 5 +++-- app/assets/javascripts/views/editor/editor_view.ts | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/views/abstract/pure_view_ctrl.ts b/app/assets/javascripts/views/abstract/pure_view_ctrl.ts index ff2379ef6..5b9bb8a78 100644 --- a/app/assets/javascripts/views/abstract/pure_view_ctrl.ts +++ b/app/assets/javascripts/views/abstract/pure_view_ctrl.ts @@ -69,8 +69,9 @@ export class PureViewCtrl
{ }); } - async updateUI(func: () => void) { - this.$timeout(func); + /** @returns a promise that resolves after the UI has been updated. */ + flushUI() { + return this.$timeout(); } initProps(props: CtrlProps) { diff --git a/app/assets/javascripts/views/editor/editor_view.ts b/app/assets/javascripts/views/editor/editor_view.ts index afb8ef9ce..482ef5a84 100644 --- a/app/assets/javascripts/views/editor/editor_view.ts +++ b/app/assets/javascripts/views/editor/editor_view.ts @@ -779,12 +779,11 @@ class EditorViewCtrl extends PureViewCtrl<{}, EditorState> { ); } - reloadTagsString() { + async reloadTagsString() { const tags = this.appState.getNoteTags(this.note); const string = SNTag.arrayToDisplayString(tags); - this.updateUI(() => { - this.editorValues.tagsInputValue = string; - }) + await this.flushUI(); + this.editorValues.tagsInputValue = string; } private addTag(tag: SNTag) {