Skip to content

Commit 5972bd4

Browse files
committed
HistoryView: Don't show the 'loading commit' thing until after 500 ms.
This was annoying me a lot, so it's in stable :) Signed-off-by: Pieter de Bie <[email protected]>
1 parent 34394d0 commit 5972bd4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

html/views/history/history.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var Commit = function(obj) {
1010
this.sha = obj.realSha();
1111
this.parents = obj.parents;
1212
this.subject = obj.subject;
13+
this.notificationID = null;
1314

1415
// TODO:
1516
// this.author_date instant
@@ -168,11 +169,12 @@ var loadCommit = function(commitObject, currentRef) {
168169
// Which will be called from the controller once
169170
// the commit details are in.
170171

172+
if (commit && commit.notificationID)
173+
clearTimeout(commit.notificationID);
174+
171175
commit = new Commit(commitObject);
172176
commit.currentRef = currentRef;
173177

174-
notify("Loading commit…", 0);
175-
176178
$("commitID").innerHTML = commit.sha;
177179
$("authorID").innerHTML = commit.author_name;
178180
$("subjectID").innerHTML = commit.subject.escapeHTML();
@@ -202,6 +204,13 @@ var loadCommit = function(commitObject, currentRef) {
202204
"<a href='' onclick='selectCommit(this.innerHTML); return false;'>" +
203205
commit.parents[i] + "</a></td>";
204206
}
207+
208+
commit.notificationID = setTimeout(function() {
209+
if (!commit.fullyLoaded)
210+
notify("Loading commit…", 0);
211+
commit.notificationID = null;
212+
}, 500);
213+
205214
}
206215

207216
var showDiff = function() {
@@ -282,6 +291,11 @@ var loadCommitDetails = function(data)
282291
{
283292
commit.parseDetails(data);
284293

294+
if (commit.notificationID)
295+
clearTimeout(commit.notificationID)
296+
else
297+
$("notification").style.display = "none";
298+
285299
var formatEmail = function(name, email) {
286300
return email ? name + " &lt;<a href='mailto:" + email + "'>" + email + "</a>&gt;" : name;
287301
}

0 commit comments

Comments
 (0)