From 47f4becf9cbb064b454421e02cf8c74482aae27d Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 31 Oct 2017 14:49:24 -0700 Subject: [PATCH 1/3] Adding visual indication a commit is in progress --- lib/views/commit-view.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/views/commit-view.js b/lib/views/commit-view.js index bd6069cb05..746eb7ca71 100644 --- a/lib/views/commit-view.js +++ b/lib/views/commit-view.js @@ -153,6 +153,8 @@ export default class CommitView { commitButtonText() { if (this.props.isAmending) { return `Amend commit (${shortenSha(this.props.lastCommit.getSha())})`; + } else if (this.props.isCommitting) { + return 'Working...'; } else { if (this.props.branchName) { return `Commit to ${this.props.branchName}`; From 4fabf526914c3dcec03d6258a0f775c76eeffabc Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 6 Dec 2017 14:48:19 -0800 Subject: [PATCH 2/3] Adding delay to "Working..." message --- lib/views/commit-view.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/views/commit-view.js b/lib/views/commit-view.js index ae10a18bc9..40ac3163cc 100644 --- a/lib/views/commit-view.js +++ b/lib/views/commit-view.js @@ -21,6 +21,35 @@ export default class CommitView { constructor(props) { this.props = props; + // We don't want the user to see the UI flicker in the case + // the commit takes a very small time to complete. Instead we + // will only show the working message if we are working for longer + // than 1 second as per https://www.nngroup.com/articles/response-times-3-important-limits/ + // + // The closure is created to restrict variable access + this.shouldShowWorking = (() => { + let showWorking = false; + let timeoutHandle = null; + + return () => { + if (this.props.isCommitting) { + if (!showWorking && timeoutHandle === null) { + timeoutHandle = setTimeout(() => { + showWorking = true; + etch.update(this); + timeoutHandle = null; + }, 1000); + } + } else { + clearTimeout(timeoutHandle); + timeoutHandle = null; + showWorking = false; + } + + return showWorking; + }; + })(); + etch.initialize(this); this.editor = this.refs.editor; @@ -154,10 +183,11 @@ export default class CommitView { (this.props.deactivateCommitBox || (this.editor && this.editor.getText().length !== 0)); } + @autobind commitButtonText() { if (this.props.isAmending) { return `Amend commit (${shortenSha(this.props.lastCommit.getSha())})`; - } else if (this.props.isCommitting) { + } else if (this.shouldShowWorking()) { return 'Working...'; } else { if (this.props.branchName) { From a0025851907750bbd4665bde052aaff068236183 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 6 Dec 2017 15:02:01 -0800 Subject: [PATCH 3/3] We don't need @autobind here --- lib/views/commit-view.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/views/commit-view.js b/lib/views/commit-view.js index 40ac3163cc..4917a92098 100644 --- a/lib/views/commit-view.js +++ b/lib/views/commit-view.js @@ -183,7 +183,6 @@ export default class CommitView { (this.props.deactivateCommitBox || (this.editor && this.editor.getText().length !== 0)); } - @autobind commitButtonText() { if (this.props.isAmending) { return `Amend commit (${shortenSha(this.props.lastCommit.getSha())})`;